Jump to content

Nik

Member
  • Content Count

    60
  • Joined

  • Last visited

Everything posted by Nik

  1. this is the bit of code Josh was referring to prevent VW from caching. I've also found that python in VW is very sensitive to tabs versus spaces. I have my external editor set to insert 4 spaces when I tab. If I copy and paste a snippet from VW to my external editor it copies it as tabs and I have to run a utility that converts tabs to spaces. import yourExternalFile import imp imp.reload(yourExternalFile) #reloads the external file so VW doesn't use a cached version vs.SetPref(412, True) #Turns off include caching
  2. Nik

    vs.GetPt()

    In python GetPt and, I assume, GetPtL (since the reference says it works similarly) don't return anything. You create a callback function and can use the point inside the callback function. You can't set a global variable equal to the point, since the main script keeps running while the callback waits for the user to select a point. At this point, I've tossed vs.GetPtL out the window, but it would be helpful if someone on the Vectorworks team could properly document the function's parameters, and how many and what parameters are needed in the callback function.
  3. Nik

    vs.GetPt()

    So I have had no sucess in trying to get vs.GetPtL to work. My guess is that it should look something like this: def cb(pt1): def cb2(pt2): print('point 1: ',pt1,' point2: ', pt2) print('point 1 in cb: ', pt1) vs.GetPtL(cb2) #<-- throws tuple index out of range #vs.GetPtL(pt1, cb2) #<-- throws invalid number of parameters to callback function #vs.GetPtL(cb2, pt1) #<-- throws invalid number of parameters to callback function #pt2 = vs.GetPtL(pt1) #<-- this is what's in the vs.py file as an example, #but it too throws invalid number of parameters to callback function vs.GetPt(cb) So I gave up and used GetRect which works (the "rubber band' is a line and not a rect) : def CB(pt0, pt1): print('-CB-') print('pt0: ', pt0) print('pt1: ', pt1) vs.GetRect(CB)
  4. okay! I learned somethings... respond2SurfaceEdit should actually be called OnInit the vsoAddParamWidget command should be in OnInit and to actually be able to add widgets and adjust their visibility/enabled state you need to include the following at the beginning of the OnInit: ok = vs.SetObjPropVS(8, True) #kObjXPropHasUIOverride} ok = vs.SetObjPropVS(12, True) #kObjXHasCustomWidgetVisibilities}
  5. Trying get a handle on using event handling for PIOs.(Pun fully intended) Mostly look to build my parameters programmatically rather than using the Plug In Manager. Here's a little script I've added to a Point object. My understanding is that I should build my parameter widgets during the respond2Widget prep event, but that event never seems to get triggered. When I select the object from my Tool Palette it triggers a respond2SurfaceEdit, then a resetEvent. When I click in the drawing to place it I get respond2SurfaceEdit, resetEvent, respond2SurfaceEdit, resetEvent. Am I missing something? If so what am I missing? Where can I find some documentation on this? code below: def eventHandler(): def resetEvent(): pioName, hPIO, recHand, wallHand = 0, 0, 0, 0 ok, pioName, hPIO, recHand, wallHand = vs.GetCustomObjectInfo() if ok: vs.Rect(0,0,1,1) def parametricPref(): None def respond2SurfaceEdit(): None def onSpecialEdit(): None def onReshape(): None def onButtonPress(): None def respond2WidgetPrep(): vs.vsoAddParamWidget(9, 'testing', 'A Test') vs.vsoSetEventResult(-8) def onParamValChange(): None def triggerEvent(argument): eventSwitcher = { 3 : resetEvent, 4 : parametricPref, 5 : respond2SurfaceEdit, 7 : onSpecialEdit, 9 : onReshape, 35 : onButtonPress, 41 : respond2WidgetPrep, 44 : onParamValChange, } # Get the function from switcher dictionary func = eventSwitcher.get(argument, lambda: "nothing") vs.AlrtDialog(func.__name__) # Execute the function return func() theEvent, theButton = vs.vsoGetEventInfo() triggerEvent(theEvent) vs.PushAttrs eventHandler() vs.PopAttrs
  6. Nik

    Using try/except

    should have been more clear... need to check if the symbol exists in the drawing symbol library. vs.GetObject works to check if a symbol has been inserted in a drawing. try/except does work for other types of errors. but maybe not for VW thrown errors? The following bit of code works as expected try: x = 9/0 except: vs.AlrtDialog('This is division by zero!')
  7. Trying to figure out a quick and easy way to see if a symbol exists in a drawing. There doesn't seem to be a straight forward way of doing this that I can find. So I figured I would use "try/except". But vw still throws an error 😕 symName = 'mySymbolName' try: vs.Symbol(symName,0,0,0) except: vs.AlrtDialog(symName+' doesn't exist in this drawing')
  8. Mostly just pop in and out when I'm testing snippets of code, or setting up a new tool.
  9. Here's what I'm trying to do: User selects an object User then selects the PIO tool and inserts the PIO PIO uses info from the selected object as a parameter value. Currently: I get the handle to the user selected object using LSActLayer or FSActLayer. Use GetRField to extract the information from the object. Run GetCustomObjectInfo to get the PIO handle Write the information to the PIO using SetRField The problem I'm having is that it appears that a PIO resets(vsoGetEventInfo #3) itself 3 times before the creation is finished. On the first reset event the handle still points at the user selected object, on the second reset event the handle is empty, on the third reset the handle points to the new PIO. Short of writing the information to a file how do I get the information from a user selected object into a PIO on creation?
  10. There were a ton of resources on vectorlabs.info Unfortunately it seems to have disappeared. Anybody know where it went or if the information was archived somewhere?
  11. Everytime I exit Plug In Manager I get a pop up that says "Only Plug-in Objects in the active document have been updated. You must close and open the other documents to update them". How do I get this this warning to stop appearing? Not having a second VW file open is not a useful answer...
  12. Nik

    Phantom Records

    That gets rid of all the records not just the ones without an associated object. I have records within the file that are not associated to an object, best as I can tell.
  13. Nik

    Phantom Records

    I have a file that has "phantom" records. They only seem to appear when I "Export Database..." of that particular Record Format. If I do a search for them using the information that's in a field nothing is selected. If I generate a worksheet within VW the "phantom records" don't appear as lines in the worksheet. Any thoughts?
  14. What are some techniques folks use to keep scripts synced across several computers without needing to go to each one and reinstall?
  15. LW requires continuos live access to the xml file. The small pauses of accessibility that are inevitable with any cloud based drive interrupts LW writing to the xml and then LW panics. Your best bet is to keep the xml file on your local drive.
  16. Awesome! Making the switch from vectorscript to python is a bit of a challenge!
  17. Having trouble getting vectorscript functions that require a vector as parameter to work properly. In the snippet of code below, I think that ang should equal 45°. But the dialog tells me -90° and then I get the error shown in the attached file: pt= [1,1] ang = vs.Vec2Ang(pt) vs.AlrtDialog(ang)
  18. What printer to use, page size for the printer to use. I can set the printable area using the SetDrawingRect.
  19. Is there really no way to change the Page/Printer setup of a sheet layer using VectorScript without resorting to the DoMenuTextByName command? There's gotta be a way!
  20. I'm having issues with importing networks that I've wrapped up as PIO with Control Geometry. If I copy and paste the PIO into the new document it works fine. If I import it as a symbol from a different file, I get the following error(replacing XXX with the name of any wrappers in the network): Traceback (most recent call last): File "", line 1277, in File "", line 614, in RunNode AttributeError: type object 'XXX' has no attribute 'Params' If I rename the wrapper it will sometimes resume working.
  21. It would also be nice to have a comment field for a node. Something that is visible like the Name field but doesn't affect the network at all. I've been using text for commenting but that doesn't get included when wrapping a node.
  22. At the most simple level, I'm looking to create a PIO that changes based on a users selection from a dropdown list. But I don't want to waste processor cycles creating everything and then deleting all but one item, which seems to be the current solution using the If node. It's not a big deal for a simple shape but it slows things down when you have many options and the shapes get more complicated.
  23. I would love a Case node. Ideally something where I can feed it an expression and a list of conditions and then only execute the nodes downstream of the correct output. Using the attached picture of a wrapper as an example. Send it a value on the "expression" input port and a list of possible values on the "conditionlist" input port. If the expression is equal to the first item on the list execute the nodes connected to the exec0 output port. If the expression is equal to the second item on the list execute the nodes connected to the exec1 output port.
  24. When does the link for those of us unable to attend the Webinar get sent out?

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...