KingChaos Posted December 18, 2023 Share Posted December 18, 2023 Hi There, is it possible that someone here can make a script out of my small marionette? Only 1 thing must be different, is has to pick the objects (criteria) not from "Fertigung Baugruppe1" but from the active Layer. br KC PS: Maybe a pythonscript works faster, i dont know then i need a pythonscript. Would be great to have such a powerful tool like this to make it start by a shortcut and saves me hours. script from network.vwx Quote Link to comment
Pat Stanford Posted December 18, 2023 Share Posted December 18, 2023 Can you explain what exactly the marionette is doing? It looks like you are looking for objects on three different layers. If they are symbols you are converting that to a groups. Changing the layer of the group to Temp Ungrouping Getting objects with a specific field value and putting them on the Duplicate Metalbau layer Getting the objects that are still on the Temp layer and deleting them. If this is correct, then it really seems it would be easier to just select the objects with the field value and move them to the Duplicate Metalabu Layer and delete everything else. What am I missing? It is going to be difficult to provide a script unless we understand what you are trying to do. Quote Link to comment
KingChaos Posted December 19, 2023 Author Share Posted December 19, 2023 Hi not exact but close to it. what i finally need is: ALL objects with DB Record Schlossereimetallbau (which has no record "ET" in article number) on the "duplikate metallbau" layer unsymboled, to stamp them. All stuff is in black-symbols, what i need. with marionette i was not able without a detour, so i made the marionette like u saw it. its impossible to copy the symbols to this layer, because of their local coordinates, they would be placed in global coordinates. So i used the desymbol note vom computerworks and by surprise it did not unsymbol it, it makes a copy (group) of it, thats great. the temp layer i only used because i had no better idea of how to make it. the cript should: 0. clean "duplikate metallbau"-layer 1. copy all objects from layer "fertigung 1" (here it would be great to pick a layer with pulldown instead of fixing it to "fertigung 1") WITH db connection to schlosserei metallbau AND WITHOUT "ET" in field articlenumber. 2. clean temp-layer My first attempt was to duplicate the whole layer, but there was no node in marionette and it tooks several minutes (a way tooooo long) to do it. BUT I would be not the worst thing, if it would be faster. the plus here is, i can conserve the group structure in which the objects are, but this is not longer needed as prio1 while i delete all stuff which is: (not connected to metallbau) OR (has ET in articlenumber) OR (is a group.) Then all groups WITH objects wont be deleted and i have the same "groupstructure" as in my constructionlayer. sry for my bad english 🙂 br KC PS: is somethin missing? Quote Link to comment
KingChaos Posted December 19, 2023 Author Share Posted December 19, 2023 bonus would be, start the script "Datentranfer Schlossere Data" a first, it is in the file. the script reads out the subrows of a filtered list in a spreadsheet and make them real rows in a different spread sheet. Thomas made it for me @Thomas W thanks ay lot. Quote Link to comment
Pat Stanford Posted December 19, 2023 Share Posted December 19, 2023 So before I start, let's confirm this one more time: Delete all objects on Duplicate Metalbau layer Select a Design Layer Copy (not move) all objects on that layer with the DB Record and no "ET" in field article number to Duplicate Metalbau layer Convert all symbols to groups I don't think there is a way to get one script to call another, but I will think about it. Machen Sie sich keine Sorgen um Ihr Englisch, es ist viel besser als mein Deutsch. Ich spreche nur ein wenig von Umkehrosmose. 😉 Quote Link to comment
KingChaos Posted January 18 Author Share Posted January 18 the marionette is working well (its taking a little bit time, but its working.), EXCEPT problems occuring with the symbolcharacter of the interiorcadparts. But this is not so problamatically, because i will make a clone of the file before, use the marionette and copy the duplicated parts in the original file. i use symbols with included interiorcadparts, they will have databaseproblems after I "symbol to group" all IF there is a symbol more then 1 time in the file. The parts are not renamed, like they will if u copy them with holding "ctrl. mouse1". another question is coming in my mind, in excel there is a makro recorder for stuff u do to get a vba code out of it. If i use the "change similar objects" button, i can make a filter and make this selection into a vectorworks script. Is it possible here, to record what i do to make my own scripts? 🙂 br KC Quote Link to comment
KingChaos Posted January 18 Author Share Posted January 18 (edited) maybe its possible to remove all the datastamps in the duplicated layer, that could fasten it up, maybe. i will check before the script "is made somehow by someone" Edited January 18 by KingChaos Quote Link to comment
MullinRJ Posted January 18 Share Posted January 18 Sadly, there is no Macro Recorder in VW. It has been requested many times. For geometry, you can draw shapes in a new file, then use menu File > Export > Export Script.... This will save a VectorScript file to disk. Using a text editor, you can extract the geometry calls to your objects and substitute any or all of the numerical parameters for variables which you can control in your script. This is a shortcut to building a script, but not the same as a Macro Recorder. If you have any questions about this, holler back. Raymond 1 Quote Link to comment
KingChaos Posted January 18 Author Share Posted January 18 how to dock variables like in an oip panel? i am new to scripts, i dont know a lot about it, how to use, how to combine, how to save or how to merge different scripts. i have some script here, i need to "merge" with that script out of my marionette Quote Link to comment
Pat Stanford Posted January 18 Share Posted January 18 To get a script to show values in the OIP you need to create a Plug-in Object. PIOs have two parts, a script and a Parameter Record. The Parameter Record items show (optionally hidden) in the OIP. So when the user changes the value in the OIP the PIO will regenerate with the new value. Parameters are "semi-constants" in the script. Their value does not change during a specific script run. So if you need to adjust the value while the script is running you need to store the value into a variable and then back into the parameter at the end of the script. You access parameters inside the script by prefixing the name with a letter P. So if you have a parameter named Height, to use that in the script would be pHeight. This post has information on making a Plug-in Menu Command. Similar to a PIO but without the parameter record. HTH 1 Quote Link to comment
KingChaos Posted January 19 Author Share Posted January 19 MullinRJ hey, i made is this the complete scriptpart of thix extrude? {Object Creation Code} NameClass('Keine'); BeginXtrd(0,500); PenSize(4); PenPatN(2); FillPat(1); PenFore(0,0,0); PenBack(65535,65535,65535); FillFore(0,0,0); FillBack(65535,65535,65535); RectangleN(0,0,1,0,890,680); objectHandle := LNewObj; SetDropShadowData(objectHandle, 0,0.1,0.05,#315.0000000000d,75,0,0,0); EnableDropShadow(objectHandle, FALSE); if yes, how to make this variable with the p? and how to make a parametertable? br NILS H. from Germany Quote Link to comment
Jesse Cogswell Posted January 19 Share Posted January 19 This post that I wrote a couple of years ago might be useful. It's a basic crash course in creating Plug-in Objects in Vectorscript. This will cover setting up parameters and pulling their data as well as cover the basic structure and syntax of Vectorscript. Your code is not too terribly complicated, but I do have some questions/notes: I see you have a BeginXtrd function but not an EndXtrd function. Vectorscript will need the EndXtrd to finish the extrusion. Generally, my recommendation is to create the geometry first and then use functions like SetLW, SetFillBack, SetPenFore, SetFPat on the newly created geometry (passing LNewObj in as the handle) rather than change the settings and drawing the geometry later. This allows you to not have to reset the settings after your object is created. When using SetFillFore, SetFillBack, SetPenFore, and SetPenBack, you can get away with only setting the PenFore and the FillBack in most instances. When in doubt, make sure that the Fore and Back settings match (so that your SetFillFore and SetFillBack values are the same). Like with the settings, it's better to use SetClass on the created geometry rather than changing the user's class settings anytime they activate your tool. With the code you have, there is no need for you to have the line with objectHandle:=LNewObj, you can just use LNewObj unless you want to retain a handle to the original rectangle after creating another object (like if you were trying to combine two objects). I am confused why you are setting a drop shadow on an extrude, especially setting the drop shadow settings with SetDropShadowData and then disabling the drop shadow with EnableDropShadow(LNewObj,FALSE). 1 Quote Link to comment
MullinRJ Posted January 19 Share Posted January 19 (edited) @KingChaos I've annotated the code you posted to show you what each line does. Then further down I offer you some options for rewriting it that may make it easier to follow. {Object Creation Code} { this sets the active class – optional } NameClass('Keine'); { the extrusion starts with this statement } BeginXtrd(0,500); { these lines define stroke, fill, and color attributes } PenSize(4); PenPatN(2); FillPat(1); PenFore(0,0,0); PenBack(65535,65535,65535); FillFore(0,0,0); FillBack(65535,65535,65535); { this is the shape to be extruded } RectangleN(0,0,1,0,890,680); { these lines define a drop shadow, which is not used so can be deleted } objectHandle := LNewObj; SetDropShadowData(objectHandle, 0,0.1,0.05,#315d,75,0,0,0); EnableDropShadow(objectHandle, FALSE); { the extrusion ends with this statement } EndXtrd; { *** you need an EndXtrd statement to make it work **** } To simplify the above code I've rewritten it here, adding comments, spaces, and removing dead code: { these lines define stroke, fill, and color attributes } { they may be included or excluded as desired } PenSize(4); PenPatN(2); FillPat(1); PenFore(0,0,0); PenBack(65535,65535,65535); FillFore(0,0,0); FillBack(65535,65535,65535); NameClass('Keine'); { set the active class – optional } { these next three lines draw the geometry } BeginXtrd(0,500); { the extrusion starts here } RectangleN(0,0,1,0,890,680); { this is the shape to be extruded } EndXtrd; { the extrusion ends here } Using @Jesse Cogswell's approach, here is another rewrite: BeginXtrd(0,500); { the extrusion starts here } RectangleN(0,0,1,0,890,680); { this is the shape to be extruded } EndXtrd; { the extrusion ends here } { the following lines are optional, and they only refer to the previously created extrude } SetClass(LNewObj, 'Keine'); { set the object's class } SetLW(LNewObj, 4); { 4 mils wide } SetLSN(LNewObj, 2); { use pen foreground color - solid } SetFPat(LNewObj, 1); { use fill background color - solid } SetFillFore(LNewObj, 0,0,0); { black } SetPenFore(LNewObj, 0,0,0); { black } SetFillBack(LNewObj, 65535,65535,65535);{ white } SetPenBack(LNewObj, 65535,65535,65535); { white } Note the use of LNewObj to reference the previously created object. Lastly, to make this adaptable to a PIO I added "p" variables where you would want to control your code. Open the Plug-In Editor to start defining your plug-in object. (Cmd-Shift-Z on a Mac, or Ctrl-Shift-Z on a PC.) Click on the NEW... button, give it a name, and select a PIO type. If you start with a Point Object PIO you will need to create three variables. Let's assume you choose the names, Length, Width, and Extrude. These are defined in the Plug-in Editor, under the Parameters tab. Make them type Dimension. In your script you will refer to these values as PLength, PWidth, and PExtrude, respectively. In your code, these are constants which means you can't change their values. Technically, you can, but it will have no effect on anything when you are done. The only lines you will need to edit are these: BeginXtrd(0, PExtrude); { the extrusion starts here } RectangleN(0, 0, 1, 0, PLength, PWidth); { this is the shape to be extruded } EndXtrd; { the extrusion ends here } Now you can paste the code into the PIO Editor, wrapped in the basic Pascal program shell. Add any of the Class, Color, or Pen & Fill commands you think are necessary and you have a simple plugin that has user defined ∆XYZ components. Note – if you assign Color and Class inside your plug-in, you won't be able to change them from the outside. Here's the minimum code that will draw an extruded box with parameters showing in the OIP: PROCEDURE xxx; BEGIN BeginXtrd(0, PExtrude); { the extrusion starts here } RectangleN(0, 0, 1, 0, PLength, PWidth); { this is the shape to be extruded } EndXtrd; { the extrusion ends here } END; Run(xxx); Now when your code runs you will be able to change all of its parameters in the OIP. The very last step is to add your plug-in to you workspace as a TOOL , and you can then place it in your drawing with a click. HTH, Raymond Edited January 19 by MullinRJ corrected call to set the Line Style (SetLSN) 2 Quote Link to comment
KingChaos Posted January 22 Author Share Posted January 22 i never made a single code in vectorspript by my own. i just tried to find the code in the exported vxw as text for getting startet creating parametrical objects without marionette. in marionette i got a few very complicated things even melissa meant (wow she said) but they are so slow in vwx, so i try to fix it with making the geometry with the code directly. BUT i have no time for this to learn while i am sketching projects in interiorcad, so i will take only smalls steps each week. 🙂 🙂 thx a lot so far. 1 Quote Link to comment
MullinRJ Posted January 22 Share Posted January 22 Well @KingChaos, You are off to a good start. There are no LARGE steps in programming, only small ones. You will find lots of support in this forum, so don't spend too much time trying to figure out confusing things on your own. Ask and you shall be answered (not to sound too preachy), at least as far as an answer exists. The Export Script trick is a good one. Use it as needed. Example code, and this forum are your next best tools. With each example you will gain confidence with the power of scripting. It is a natural fit for CAD work. Sometimes Marionette will be all you need, but Vectorscript and Python offer different ways solve the same problems. Each has strengths over the other. Hope to see you again, soon. Raymond Quote Link to comment
MullinRJ Posted January 22 Share Posted January 22 I forgot to ask, were you able to add the code above to a Point Object PIO? If you need help with that, just ask. Raymond 1 Quote Link to comment
KingChaos Posted January 22 Author Share Posted January 22 not at this time, but i think i will make it. before i used topsolid and there is not a single line, square or circle without any callable parameter in the topsolid. so there is nothing complicated scripting needed like here. All stuff is assoziative and follow IN REAL TIME all modifications u make. So as i started VWX i was only able to cry about this "dead geometry " 😛 Quote Link to comment
KingChaos Posted January 22 Author Share Posted January 22 (edited) ok i think i can make it. But, how to make a red symbol out of it to use it in my xtragroup cabinet as a "box object"? Edited January 22 by KingChaos Quote Link to comment
KingChaos Posted January 22 Author Share Posted January 22 i think it would be possible to hollow, drill and cut objects ^^ with script to make somethin like this: And later i think it will be possible to make presets (styles) of parametersets? Quote Link to comment
KingChaos Posted January 22 Author Share Posted January 22 ok, i tried now to make an extrude and hollow it. i cant find this "hollowed extrude" in the script ^^ Quote Link to comment
KingChaos Posted January 22 Author Share Posted January 22 hey, ok i ran the tool and it works. Now i need to know, how i can make a symbol out of it with OIP parameter ports. After this i will try to hollow the extrude. Quote Link to comment
KingChaos Posted January 22 Author Share Posted January 22 the marionette i made (500 nodes) compiled 20 min to object and was very bad. this is faster with 150 nodes but its to slow. so i made it slimmer but it took several minutes to update, after i modified the xg cabinet, where i used it as a box object. the problem is, that marionette does a spaghetticode, useless lines of code each node so this is not the way i can use. Quote Link to comment
MullinRJ Posted January 22 Share Posted January 22 If I was going to script my solid, I would probably use SubtractSolid() to make a shell. There is also the Shell Solid Tool, if you are drawing manually. To use SubtractSolid(), create an extruded solid, duplicate it in place, shrink the duplicate (and possibly move it to create an open carcass), then subtract it from the first solid. There are other ways to achieve the same result. You can also extrude the outer sides of the box, 5 or 6 sides, and use AddSolid() to each one sequentially to build up the same solid. You can also extrude the back, then extrude a hollow Polyline for the walls, and use AddSolid() to join them. If you have further questions on Solid Geometry, check out the SOLIDS MODELING AND 3D PRINTING section in Solids Modeling and Subdivision in this Forum. Everything you want to do can be done. Baby steps will you get there. When you get a routine finished in VS or Python, you'll be amazed how fast it will run. All the best, Raymond Quote Link to comment
Jesse Cogswell Posted January 22 Share Posted January 22 (edited) EDIT: Nevermind, it looks like you already got this far and I misread your question. @MullinRJ's advice in the next post is more likely to be what you are looking for. To get the parameters into the Object Info Palette, you need to build the plug-in object as a Point Object or Rectangle Object, right now it looks like you have it set to a Tool. If I were in your shoes, I would probably make it a Point Object to get around some of the oddities in placing Rectangle Objects. The post that I linked above and am linking again has all of the steps you need listed out. Look for the section called CREATING A NEW PLUG-IN, it has instructions on building the parameters. Essentially, you need to build the background record that serves as the plug-in parameters. You will set these parameters in a window that looks like this: The Name column will be the name that the script is looking for, referenced in script by that name with a capital "P" in front. For the example above, you would have code something to the tune of boxWidth:=PBoxWidth; The Alternative Name column will be what the parameter is named in the Object Info Palette. Edited January 22 by Jesse Cogswell 2 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.