nkunstle Posted June 12, 2018 Share Posted June 12, 2018 New to scripting for vectorwork, so apologies if I am asking a simple question... I am scripting a PIO that includes a collection of lights, I want to put a parameter in the OIP that works like the color picker that shows up there when inserting an individual light. Functionally I can do numerical fields to capture the RGB data but without the color picker it's a long processes to get the right color. Is there any way to put a "color" parameter in a python script so that it shows up in the OIP as a color picker button? Quote Link to comment
JBenghiat Posted June 13, 2018 Share Posted June 13, 2018 The light objects are part of Vectorworks’ core, so their interface elements aren’t part of any of the APIs. As far as I know, you’ll have to use a button widget to call a custom dialog with a color pop up. Quote Link to comment
nkunstle Posted June 18, 2018 Author Share Posted June 18, 2018 On 6/12/2018 at 10:50 PM, JBenghiat said: The light objects are part of Vectorworks’ core, so their interface elements aren’t part of any of the APIs. As far as I know, you’ll have to use a button widget to call a custom dialog with a color pop up. Thanks for the quick response. Trying to work through creating the custom dialogues, I'll let you know my progress in a few days. Is there a direction you can point me to in order to learn how to insert the button widget in the OIP? Most of the OIP stuff I have done so far are parameters defined by the "Parameters" tab in the "Edit Definition" window. Quote Link to comment
JBenghiat Posted June 18, 2018 Share Posted June 18, 2018 Search the archive (including Vectorscript) for event enabled objects. You will have to add some more structure to your code to handle events (your current code goes in the reset event). The InitXProperties event allows you to add buttons (as well as set other properties), and you will also get an event when the user clicks on a button. 1 Quote Link to comment
nkunstle Posted June 21, 2018 Author Share Posted June 21, 2018 Josh, Custom menu now working now just trying to get the OIP button. I am rewriting the Vectorlab Events demo3 from Vectorscript to Python so I understand how events work. @JBenghiat Thank you so much fo all of your help, not sure I would even have made it this far without your help!! Still having an issue with my event based scripts. The code below compiles and executes without errors however the code in the reset block never runs, so I never get my rect object. I am VERY new to this so I am sure there is a rookie mistake somewhere, . Also if you see other things in the code structure that I can improve let me know, just learning python so I am sure the code has room to improve. import vs def run(): #Declare constants kObjOnInitXProperties = 5 kResetEventID = 3 kObjXPropPreventWallInsertion = 7 kObjXPropHasUIOverride = 8 kWidgetButton = 12 kObjOnObjectUIButtonHit = 35 buttonID_1 = 1234 thisDoesNothing = 0 #this call gets the event ID and button if applicable theEvent, theButton = vs.vsoGetEventInfo() #If its the property inialization event - Do this if theEvent == kObjOnInitXProperties: vs.SetObjPropVS(kObjXPropPreventWallInsertion, True) vs.SetObjPropVS(kObjXPropHasUIOverride, True) vs.vsoInsertAllParams() sourceFieldNumber = 1 displayString = 'My Great Field Name' vs.vsoAppendParamWidget(sourceFieldNumber, displayString, thisDoesNothing); displayString = 'My Great Button'; vs.vsoAppendWidget(kWidgetButton, buttonID_1, displayString, thisDoesNothing); #If The button is pressed detect which button and Do this elif theEvent == kObjOnObjectUIButtonHit: if theButton == buttonID_1: vs.AlrtDialog('Custom Button Dialog') #Where the standard PIO scripting goes to generate the object when reset us called elif theEvent == kResetEventID: vs.Rect(0, 0, 1, 1) run() Quote Link to comment
JBenghiat Posted June 21, 2018 Share Posted June 21, 2018 Just a quick glance, but python uses leading white space to determine code structure. I think you have some extra space before the final elif. 1 Quote Link to comment
nkunstle Posted June 21, 2018 Author Share Posted June 21, 2018 Facepalm 🤦♂️, can't believe I missed that, I think I stared at that code for an hour before I gave up. Anyway thanks for helping me find my solve! 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.