matteoluigi Posted July 6, 2022 Share Posted July 6, 2022 I want to read out the size of German void Objects (Schlitze & Durchbrüche). Afaik it's a float variable in the record format 'Break Opening CW','Delta_x', 'Break Opening CW','Delta_y', 'Break Opening CW','Delta_z' I don't want to read out the numbers in 0,xxx meters but in xxx cm. So i multiply the value by 1000. however the result from the script operation is never xxx but always either 0,xxxxxxxx-e01m or x (also all void objects do have a 0,xxx size and I multiply that 0,xxx size by 1000) I also created a worksheet, which reads out the same variables. ='Break Opening CW'.'Delta_x'*1000 ='Break Opening CW'.'Delta_y'*1000 ='Break Opening CW'.'Delta_x'*1000 here the multiplication does work instead that's so strange to me. 0,250*1000 should be 250 and not 2,00, 0,500*1000 should be 500 and not 5,00... I tried a lot, Num2StrF, Num2Str(0,...), multiplication by 1000000, no multiplication,... every time I use Num2Str 0,xxx changes in x. I don't really understand, what's going on there... ( i also attach the vwx 2022 SP3 file) def parentobjectcheck(SDBH): HNDL=vs.GetParent(SDBH) SDBx = vs.GetRField((SDBH),'Break Opening CW','Delta_x') SDBx = vs.Num2Str(2,SDBx*1000) # SDBx = vs.Round(SDBx) SDBy = vs.GetRField((SDBH),'Break Opening CW','Delta_y') SDBy = vs.Num2Str(2,SDBy*1000) # SDBy = vs.Round(SDBy) SDBz = vs.GetRField((SDBH),'Break Opening CW','Delta_z') SDBz = vs.Num2Str(2,SDBz*1000) # SDBz = vs.Round(SDBz) vs.SetRecord(SDBH, 'DB-BAUTEILKUERZEL') vs.SetRField((SDBH),'DB-BAUTEILKUERZEL','01 Bauteilkuerzel',(vs.Concat(SDBx,'-',SDBy,'-',SDBz))) vs.ForEachObject(parentobjectcheck,"(INSYMBOL & INOBJECT & INVIEWPORT & (PON='Break Opening CW'))") void-dimensions.zip Quote Link to comment
Pat Stanford Posted July 6, 2022 Share Posted July 6, 2022 vs.GetRField always returns the String value of the field and appears to be returning the unit mark as well. Str2Num does not handle the unit mark for that you need to use vs.ValidNumStr. Something like this seems to work. SDBx = vs.GetRField((SDBH),'Break Opening CW','Delta_x') B1, SDBxR = vs.ValidNumStr(SDBx) SDBx = vs.Num2Str(2,SDBxR*1000) 1 Quote Link to comment
Pat Stanford Posted July 6, 2022 Share Posted July 6, 2022 Alternatively, you could use Python code to remove any non-numeric values read inform the record field and then stick to Str2Num for the conversion. But I am a Vectorscript/Pascal guy not a Python wiz, so I am not going there. 😉 1 Quote Link to comment
Nicolas Goutte Posted July 7, 2022 Share Posted July 7, 2022 17 hours ago, matteoluigi said: I don't want to read out the numbers in 0,xxx meters but in xxx cm. So i multiply the value by 1000. Be careful: 1 m is 1000mm but only 100 cm. Quote Link to comment
matteoluigi Posted July 7, 2022 Author Share Posted July 7, 2022 47 minutes ago, Nicolas Goutte said: Be careful: 1 m is 1000mm but only 100 cm. that's right! however 0,250*1000!=2 😉 Quote Link to comment
matteoluigi Posted July 7, 2022 Author Share Posted July 7, 2022 @Pat Stanfordvs.ValidNumStr did it. Thank you!!! 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.