Jump to content
Developer Wiki and Function Reference Links ×

RGB Value from Gel Name


AlHanson

Recommended Posts

Is there any way to get colors from the existing color libraries in Vectorworks via vectorscript- particularly for spotlight gel colors? Clearly it's there as the Color field on a lighting device can access the color libraries this way, but there doesn't seem to be a function that I can  track down which gives a similar functionality. I've already previously built my own custom dictionary with gel names and RGB values that works great for what I'm doing, but it really seems like I shouldn't have to go this route of loading in hundreds of values manually when the information already exists in the program. Any thoughts?

Link to comment

This is totally possible and relatively simple.  All of the RGB information for gel colors is stored in a resource file inside your VW installation file.  The easy way to get to it is to use FindFileInPluginFolder to pull the file, then use Open to open the file, then do a WHILE NOT EOF loop on the file to read each line using ReadLn.  The information is stored in the following manner: manufacturer, ID number, red value, green value, blue value.  All RGB values are 16-bit.

 

For example, the output for R09 is stored as "R 9 65535 49344 35466" in the file.  On Windows, the file is stored in C:\Program Files\Vectorworks <version number>\Plug-Ins\VW_Spotlight\Data\ and is named something like Rosco Colors.txt or Lee Colors.txt.

 

Keep in mind that you will need to strip the leading zeros from the ID number in the case of the lower Rosco gels (R02, R09, etc) if you are doing a direct string comparison.  This was a bug for a long time in VW, if you didn't put the color in as R2, VW wouldn't use the color in renderings.

 

If you want some example code of how to do this, I can PM you the code from my Magic Sheet plug-in.

Link to comment

Perfect! I didn't realize that information was just hanging out in such an easily accessible place... Was hoping they had made this a built in function already to do this more simply, but clearly not. Your information was perfect! I was able to whip this together in no time. Thank you much!

 

My only tangential question then would be which is more practical? Running the file read code every time it needs to look up the data or simply including a dictionary put together from all this data. The files make more sense in terms of always getting the most current data (but how much are the gel libraries really changing these days?)  but this is more code to run through on each run (which is still not very many lines). Ultimately I'm sure it makes no noticeable difference whichever route is used as it's all instantaneous and file sizes are miniscule. Just curiously pondering- I'm still fairly green at coding (I wrote the entire thing in python with the exception of the vs.FindFileInPluginFolder command you suggested).

 

 

  • Like 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.

Guest
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...