Jump to content

Color parameter (with picker) in OIP

Recommended Posts

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? 

Link to comment
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.

Link to comment

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.

  • Like 1
Link to comment

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)
  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)


Link to comment

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.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...