-
Posts
225 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Articles
Marionette
Store
Posts posted by Patrick Winkler
-
-
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
-
-
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)
-
- 1
-
The internal name can differ from the display name.
In your case it's Rebuild Curve/Surface
regards,
Patrick
-
FPenPatN is the solution.
thanks
-
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
-
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 )
-
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? )
-
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.
- 1
-
Couldn't find a description in the online help. How is it done?
-
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:
- 1
-
Hi callum,
try it with ResetObject(handle)
-
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 :))
-
Run it in 3D view and it will rotate.
-
Hi Hans,
could you provide a vwx file to reproduce the problem.
-
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
- 4
-
@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.
-
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.
- 1
-
On 8.9.2016 at 9:30 PM, Marissa Farrell said:
A magician never reveals her secrets
In all seriousness, I'll be more than happy to give you a run down of my tricks once I stomp out some of the work I've got going on here. I've been a little swamped with testing 2017 features/installers/etc., but I would imagine once we release I should have the reigns loosened up on me at least a little. (Not that they're incredibly tight to begin with - how do you think I learned Marionette AND Python in less than a year?!)
I'll keep in touch on this
I hope meanwhile you found time to finish your script.
I'm still curious about your solution.
-
Hi Dom,
handling global vars looks like a dangerous thing to me.
You have to be very carefull when connecting the nodes because it can change the flow of the network (first connected -> frist executed)
which may lead to inconsistent values. (global var is accesed before assigned...).
It seems that the flow also depends on the node from which you run the network.
I've attached an example.
regards
- 1
-
You got it pat
I could solve it by replacing the += with .append:
def RunNode(self): dir = self.Params.dir.value obj = self.Params.obj.value a = 0 b = self.Params.step.value c = self.Params.count.value list = [] if c != 0: list = [a+n*b for n in range(c)] objs = [] for i in range(len(list)): if dir == 0: objs.append (vs.HDuplicate(obj, list[i], 0)) # Changed += to append elif dir == 1: objs.append (vs.HDuplicate(obj, 0, list[i])) # Changed += to append self.Params.array.value = objs
The node creates 5 duplicates so you get 6 object s in total at the end. The original was not passed out the Linear Array node.
I appended a Delete-node to the Line-node, maybe you want to at it rather to the output list of linear array.
regards
-
Thanks pat.
I needed some attempts to get back from the str to the vs.Handle.
The cells get filled with this code:
h = vs.WSScript_GetObject() h_str = str(h) vs.WSScript_SetResStr(h_str)
Then another script iterates trough all objects and compares the handle strings:
def get_handle_from_str (h_str): h_dict = {} # key: handle_str val: handle def collect_handles(h): nonlocal h_dict h_dict[str(h)] = h vs.ForEachObject (collect_handles, 'All') try: h = h_dict [h_str] except KeyError: print ('Handle could not be found.') h = None print (h_dict) return h # EXAMPLE h = get_handle_from_str ('AEC62080') vs.SetSelect (h)
It's kind of unpracticle and carries the risk if inconsistency but it works.
-
Hi Matt,
any Python-IDE can do this.
You can either put the vs.py next to your other py modules or better add a search path to the project that links to a folder where the vs.py is located.
Then you have to import it in the modules where vs-functions are called.
import vs
I use pydev for eclipse. The search path can be added in the project properties.
- 2
ConvertToPolygon() - Resolution
in Python Scripting
Posted
Thanks, I will copy your explanation into the wiki if you don't mind.