AlHanson Posted February 28, 2021 Share Posted February 28, 2021 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? Quote Link to comment
Jesse Cogswell Posted March 1, 2021 Share Posted March 1, 2021 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. Quote Link to comment
AlHanson Posted March 1, 2021 Author Share Posted March 1, 2021 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). 1 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.