Patrick Winkler

Member

225

1. Simple Customizable Shelf

Version 1.0.0

This network creates a simple but highly customizable shelf.

Couldn't find a description in the online help. How is it done?
3. ConvertToPolygon() - Resolution

I'm not sure which resoltuion to use for ConvertToPolygon(). http://developer.vectorworks.net/index.php/VS:ConvertToPolygon <50 is obvious to less. 90 and 100 convert a cirlce to 32pt polys and 150 to 64 pt polys. In this case 90 should be enough as even in renderworks my eyes can't spot a difference to the higher resolutions. It would be good to know how the resoltution effects the outcome (why do 90, 100 create the same ) and if there is a maximum value. regards, Patrick
4. ConvertToPolygon() - Resolution

Thanks, I will copy your explanation into the wiki if you don't mind.
5. Help finding center of Symbol!

To make sure the center stays at the same location the bounding box must always have the same size. This can be accomplished by palcing an invisible circle into the symbol. ( set fill and penstyle to empty.)
6. Help finding center of Symbol!

This node gives you the center of the Bounding Box. ''' Changed on 22.02.2016 : Wrong Var was used in the calcul. of the center Changed on 04.04.2016 : Created the 'def GetBBoxN (h)' Changed on 18.04.2016 : set Initialize function: Marionette.InitializeView Changed on 27.11.2017 : Force TopView author: patrick winkler ''' import vs import Marionette @Marionette.NodeDefinition class Params(metaclass = Marionette.OrderedClass): this = Marionette.Node( 'Get Bounding Box' ) this.SetDescription("Returns the bounding box's coordinates of the projection of an object on the screen plane") # IMPORTANT: SetThe View to Top while Execution - The BB Values are otherwise incorrect!!!! this.SetInitFunc(Marionette.InitializeView) this.SetFinalFunc (Marionette.RestoreView) obj = Marionette.PortIn(vs.Handle(0)) obj.SetDescription( "The input object" ) topL2D = Marionette.PortOut() topL2D.SetDescription( "The top left coordinates of the bounding box" ) botR2D = Marionette.PortOut() botR2D.SetDescription( "The bottom right coordinatesr of the bounding box" ) width = Marionette.PortOut() width.SetDescription("The width of the bounding box.") height = Marionette.PortOut() height.SetDescription("The height of the bounding box.") center = Marionette.PortOut() center.SetDescription("The centerpoint of the bounding box.") def RunNode(self): def GetBBoxN (h, top_view = True): ''' Returns top left point, bottom right point, width, height and center of the object bounding box (as tuple). IMPORTANT: The result depends on the view in VW if top_view is False. ''' if top_view: # Change the view to Top temporarily orig_view = vs.GetView() vs.SetView(0, 0, 0, 0, 0, 0) box = vs.GetBBox(h) topL2D = box[0] botR2D = box[1] center = [None, None] BB_width = botR2D[0] - topL2D[0] BB_height = topL2D[1] - botR2D[1] center[0] = topL2D[0] + BB_width / 2 center[1] = topL2D[1] - BB_height / 2 center = tuple (center) if top_view: # Restore the original view xAngle, yAngle, zAngle, offset = orig_view xDistance, yDistance, zDistance = offset vs.SetView(xAngle, yAngle, zAngle, xDistance, yDistance, zDistance) return (topL2D, botR2D, BB_width, BB_height, center) obj = self.Params.obj.value if not obj: raise ValueError('No object handle was provided!') topL2D, botR2D, BB_width, BB_height, center = GetBBoxN(obj, top_view = True) # SET THE OUT PORTS self.Params.topL2D.value = topL2D self.Params.botR2D.value = botR2D self.Params.width.value = BB_width self.Params.height.value = BB_height self.Params.center.value = tuple (center)

I looked it up in the source This list should contain all the real nams. univ_nams.txt

The internal name can differ from the display name. In your case it's Rebuild Curve/Surface regards, Patrick
9. Points along Object

Version 1.0.0

This script converts the provided object into a NURBS and puts X points alog it.
10. Get Active LineStyle

It might be obvious but I can't find the fucntion that returns the active LineStyle (Attribute Palette). Can someone give me a hint. http://developer.vectorworks.net/index.php/VS:Function_Reference#Document_Attributes Patrick
11. Get Active LineStyle

FPenPatN is the solution. thanks
12. Create and export custom Reports - Vectorscript or SDK?

You can find additional indo and more examples on http://www.vectorlab.info I would recommend you pyodbc (or pypyodbc*) for the sql connection. It is easy to use, more stable and performs better than the vs. functions. * Almost totally same usage as pyodbc ( can be seen as a re-implementation of pyodbc in pure Python )
13. 3D_Polys_to_2D

Version 1.0.0

This little script flattens all the 3D Polys in the drawing to 0 and converts them into 2D polys without removing the attached database. 3D_Polys_to_2D_VW2017.vwx
14. PythonExecute - How to assign the Pythonscript?

Hello, I need to call a Pythonscript (200 Lines!) wrappt in a VectorScript. Can you tell me how to get it between the brackets in VS? PythonExecute ( ?Load Pythonscript from external file? )
15. New Nodes 2018

Function is a great timesaver node. Here is a version with two more optional params. I have to contain myself from using it to extensive because the readability of the code could suffer. It would be great for the future if the function was displayed on the node. function_N.vwx
16. New Nodes 2018

thanks Dom, I wonder why the criteria-dialog only calls a string-dlg as there is a more sophisticated dialog available. Here is the alternative version: crit_dlg_N.vwx.zip
17. Record fields not updating after script

Hi callum, try it with ResetObject(handle)
18. Rotating custom objects?

Hans, you just mentioned the solution. I forgot that there is a transfrommatrix-node. The Rotate3D node could be fixed by checking the type for PlugIn objects and using TransfMatrix in case. (@Marissa Farrel :))
19. Rotating custom objects?

Run it in 3D view and it will rotate.
20. Rotating custom objects?

Hi Hans, could you provide a vwx file to reproduce the problem.
21. Developer Tip: Using vs.Handle Attributes

Hello together, when using the pydev debugger I noticed that vs.Handle provides some attributes that make scripting a bit more comfortable. Hopefully more attributes will follow. def test(): vs.CreateText('Hello!!') h = vs.LNewObj() print ('Type', h.type) print ('Parent', h.parent) print ('Parent Type', h.parent.type) regards, Patrick
22. Dropdown List for Symbols?

@Marionette.NodeDefinition class Params(metaclass = Marionette.OrderedClass): def get_SymDefs_in_File (): ''' Returns all Symbol-Definitions as list found in the active Document. ''' syms = [] SYMBOL_DEFINI_TYPE = 16 CURRENT_DOC = 0 Res_List, NumItems = vs.BuildResourceList (SYMBOL_DEFINI_TYPE, CURRENT_DOC, '') for i in range (NumItems): # Die Resourcelist beginnt nicht wie üblich mit dem Index 0 sondern mit 1 i += 1 h = vs.GetResourceFromList (Res_List, i) syms.append ( vs.GetName(h)) return syms ### this = Marionette.Node( 'Get Sym' ) sym_list = get_SymDefs_in_File () sym_popUp = Marionette.OIPControl( 'Syms', Marionette.WidgetType.Popup, 0, sym_list) sym = Marionette.PortOut() def RunNode(self): sel_idx = self.Params.sym_popUp.value self.Params.sym.value = self.Params.sym_popUp.popupChoices[sel_idx] Unfortunately you have to run it to refresh the popup values.
23. Hexagon Grid / Honeycombs

Version 1.0.0

Here is a wrapper for creating honeycombs.
24. Print Node

Version 6.1

This Node makes debugging more comfortable especially inside wrappers. You can select weather if the incoming values will be printed into a text object right under the node or into the python console. Time of the execution and type of the items can be printed optionally. I integradet the object type list from the appendix site to translate the type id into a string ( 5 = Polygon... ) You can also define filter conditions as Python statement in the oip of the node. Variable X is replaced by the values. Check out the example in the VWX.
25. global variables in a marionette script

I've changed the Marionette.py to make it capable of showing the exceution order. I think this can also be helpfull in other cases then global var handling. You have to replace the Marionette.py inside the marionett plugin by the attached one (on your own risk). It only shows the order on the first outport if there is a vw class named 'mrnt_show_order' in the doc otherwise it shows the number of output values as usual. Marionette.py.zip