Juliensv Posted November 9, 2023 Share Posted November 9, 2023 Hey y'all, I'm trying to get the length of an existing dimension, but I'm not sure how to go about it. I can get the "text" of the dimension with GetDimText but it's rounded to the dimension precision, and it's also a string which I need to parse to get the actual value. I'd like to get a REAL in the document unit precision. I've tried multiple methods, Hlength, HPerim, , which haven't garnered good results. The closest I can get is using Get2DPt, which works with aligned dimensions, but it's complicated with Linear Dimensions that have different offsets on each witness line, because Get2DPt only gives the location of the end of each witness line. I've tried screwing around with the witness line override selectors but that doesn't change the Get2DPt. Dimension Offset selector 45 only gives the length of the "first" witness line, so there's nothing to compare to figure out the orientation/offset of a constrained linear dim. Do y'all have any ideas how to get this? I'm sure I'm missing an obvious answer. Thanks in advance! Quote Link to comment
Pat Stanford Posted November 9, 2023 Share Posted November 9, 2023 I don't think what you want exists. I used ValidNumberString to convert the text value into a Real in a Worksheet Script I was playing with. Procedure Test; Var B1:Boolean; R1:Real; Begin B1:=ValidNumStr(GetDimText(WSScript_GetObject),R1); WSScript_SetResReal(R1); End; Run(Test); That should get you the value with the "correct" document units, but test and see. You may need to script your own routine to take a Real and "round" it to the document units precision. HTH 1 Quote Link to comment
MullinRJ Posted November 11, 2023 Share Posted November 11, 2023 @Juliensv, Are you wanting the value to use in a worksheet, or just in a script? For accessing the length in a script, here's an example that shows the exact length in document units but w/o the units string displayed. PROCEDURE xxx; { Show the length of a selected dimension object. } { 10 Nov 2023 - Raymond J Mullin } VAR H :Handle; B :Boolean; P1, P2 :Vector; BEGIN H := FSActLayer; if (GetTypeN(H) = 63) then begin { Dimension object } B := GetObjectVariablePoint(H, 13, P1.x, P1.y, P1.z); { point 1 } B := GetObjectVariablePoint(H, 14, P2.x, P2.y, P2.z); { point 2 } AlrtDialog(concat('Dimension Length = ', Norm(P2-P1))); { display length } end { if } else AlrtDialog('Selected object is not a DIMENSION object.'); END; Run(xxx); If you want to control the number of decimals displayed in the answer, use the Num2Str() function around the Norm() function, or if you want the answer formatted using the current document units, use the Num2StrF() function. Lastly, if you want the answer for use in a Worksheet function, a some lines will need to be added and removed. HTH, Raymond 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.