htranbos Posted February 14 Share Posted February 14 I am writing a small script to create Shell Solid for a selected object. The current Document Settings units is in decimal inch. In the below script, I want to create a shell solid at 2" thickness. However, after running the script, the shell object thickness is at .079". Is there a way to convert REAL number to the correct unit in inches? h = vs.FSActLayer() vs.CreateShell(h, 2) Thanks Quote Link to comment
JBenghiat Posted February 14 Share Posted February 14 Just flagging that this is in the VectorScript forum, but your code is in Python. This is one of the few things that VS does more easily: you can just specify units, i.e. CreateShell(h, 2”). In Python you have to do unit conversions. vs.ValidNumStr is the most robust https://developer.vectorworks.net/index.php?title=VS:ValidNumStr Just to throw a wrench in things, I believe some functions always take millimeters, and this may be one of them. Best practice there is to retrieve the units per inch preference, and convert input numbers into millimeters. 1 Quote Link to comment
htranbos Posted February 14 Author Share Posted February 14 @JBenghiat Thank you! I did not realize there is a separate forum for Python Scripting. I started to mess around with units per inch preference but haven't been able to make it to work. I will play around with it some more. Quote Link to comment
htranbos Posted February 14 Author Share Posted February 14 @JBenghiat Finally I am able to make it to work. Below is what I did: h = vs.FSActLayer() upi = vs.GetPrefReal(152) #Calculate unit per inch preference thickness = 25.4*upi*2 #Converting mm to in (1in = 25.4mm). This statement set thickness to 2" vs.CreateShell(h, thickness) 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.