twk Posted November 3, 2015 Share Posted November 3, 2015 Greetings all, The vectorscript language had a neat feature where in your code you force values to have a certain dimension regardless of the Document Unit settins. eg. Procedure UnitThing; VAR somvalue : REAL; Begin; somevalue := 50mm; MoveTo(0,0); LineTo(somevalue, 0); end; Run(UnitThing); A line would be drawn to 50mm regardless of the documents units. If the doc units were set to Feet and Inches it would draw a line of 1.9685" in length. however in python I can't seem to get this to work. Am I correct to assume that this won't work in python? Quote Link to comment
Hippocode Posted November 3, 2015 Share Posted November 3, 2015 Vectorworks stores dimensions in WorldCoord which at this point is equal to one mm. When you used 50cm in VS it would automatically convert it into 500. Regardless of the unit settings, that is the value, always. When showing the coordinates to the user, the value is modified based on the unit settings, but the length is always the same. Can't this function do the same ? http://developer.vectorworks.net/index.php/VS:Str2Num Quote Link to comment
Dieter @ DWorks Posted November 4, 2015 Share Posted November 4, 2015 (edited) You can use vs.ValidNumStr("50mm"). Please take a look at dlibrary, where it is used in a much friendlier way. The Units class helps you with converting stuff and doing calculations. I would advice you to convert to inches, do the math, and than convert back to what you need. Because you can start with length units and end up with area units or volume units. Edited November 4, 2015 by Dieter @ DWorks Quote Link to comment
twk Posted November 23, 2015 Author Share Posted November 23, 2015 Thanks for the replies. I never knew the VW stored dimensions in worldCoordinates as 'mm' Just tested the Str2Num() and it didn't work. However the vs.ValidNumStr() call did. unitStr = '50mm' #unitNum = vs.Str2Num(unitStr) chk, unitNum = vs.ValidNumStr(unitStr) vs.Message(str(unitNum)) vs.MoveTo(0,0) vs.LineTo(unitNum, 0) the unitNum value draws a 50mm string regardless of document units. ..Interesting.. thanks again, Dieter and Hippothamus; Tui Quote Link to comment
Hippocode Posted November 23, 2015 Share Posted November 23, 2015 I never knew the VW stored dimensions in worldCoordinates as 'mm' Tui Just don't make the mistake to assume it's mm. We don't know for sure if it will be kept the same way in future releases. Always use the appropriate functions to create the "length" you need. Quote Link to comment
Dieter @ DWorks Posted November 24, 2015 Share Posted November 24, 2015 VW doesn't store them as 'mm'. It will give you the values in the document units, whatever they may be, and it will do convertions behind the scenes to store the values.... 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.