michaelk Posted October 29, 2023 Share Posted October 29, 2023 Good question. It certainly doesn't look like textFlag does what I expect it to do. From the appendix: Try this experiment and see if it makes sense to you: PROCEDURE Test; VAR i, dimType,arrow,textFlag : INTEGER; offSetDist,textOffset : REAL; BEGIN offSetDist := 0; dimType := 0; arrow := 1; textOffSet := -9; FOR i := -1024 TO 1024 DO BEGIN LinearDim(0,i*24,144,i*24,offSetDist,dimType,arrow,i,i); SetDimNote(LNewObj,Concat(i)); END; END; RUN(Test); Quote Link to comment
michaelk Posted October 29, 2023 Share Posted October 29, 2023 If the text flag is odd, then the dimension is centered and above the line. If the text flag is divisible by 2 - but not divisible by 4 - then the dimension is immediately to the left if negative and right if positive. If the text flag is divisible by 4 then the dimension is offset by the text offset value to the left if negative and right if positive. I don't see any way to make the text offset vertically. Quote Link to comment
Sam Jones Posted October 29, 2023 Author Share Posted October 29, 2023 This is a big problem for using dimensions in VS. I can get the dimension value text to the center between ends by using the calculated position, but I need to align the dimension text with the dimension line. Dimensions below an object shove the dimension text into the object and it is important that the dimensions on all sides look the same in text style and spacing. This is not possible if the text cannot be aligned to the dimension line. This has the potential of scuttling the automation of this graphic. Quote Link to comment
Pat Stanford Posted October 30, 2023 Share Posted October 30, 2023 This is using a Byte to store a bunch of Boolean values. 1 = 2^0 2=2^1 4=2^2 8=2^3 16=2^4 32=2^5 64=2^6 128=2^7 256=2^8 512=2^9 1024=2^10 2048=2^11 etc. If you look at this in binary, it looks like 0 0 0 0 0 0 0 0 0 0 0 0 2 1 5 2 1 6 3 1 8 4 2 1 0 0 1 5 2 4 2 6 4 2 2 6 8 8 4 This is an easy way to store multiple boolean values into a Byte or Word (Probably 16 bit or even 32 bit instead of the 11 bits I have shown). You can use the basic Boolean operations of AND, OR, and XOR to set or retrieve the value of an individual bit. If you want to set a bit you only have to know which bit is is and use an OR function. Word OR 4 will set bit 2 (the first bit is bit zero) without changing or caring about any of the other bits. Word AND 4 will return a value if bit 2 is a 1 (boolean true) without caring about any of the other bits. You can also just add up the values for each bit you want in an Integer. for textFlag 2 + 256 = 258 should give you text outside the dims and above the Dim line. I had already written the above before I realized that was not the problem, so I am leaving it. Real answer in the next post. 1 1 Quote Link to comment
Pat Stanford Posted October 30, 2023 Share Posted October 30, 2023 The Real Answer™ is that the documentation is lying to us. The Text Offset parameter in the LinearDimension function is not the distance above the line that is show in the Function Reference. It is actually the horizontal distance along the line in what I think are Page (unscaled) document units. What you actually need is the ObjectVariable to set the true Offset Above Dimension Line which is 44 (from the Appendix). The following should get you most of what you want. The only thing missing is to set the Fill to White so the Dimension Line is "broken" where the text is at. And the ResetObject after the SetObjectVariable is mandatory. HTH PROCEDURE LinearDimTest; VAR x1, y1, x2, y2 :Real; offSetDist :Real; dimType :Integer; arrow :Integer; textFlag :Integer; textOffset :Real; BEGIN offSetDist:=0; dimType:=0; arrow:=769; textFlag:=1; textOffset:=0"; LinearDim(0,12, 144,12, offSetDist, dimType, arrow, textFlag, textOffset); SetObjectVariableReal(LNewObj,43,0"); ResetObject(LNewObj); END; RUN(LinearDimTest); 1 1 Quote Link to comment
Sam Jones Posted October 30, 2023 Author Share Posted October 30, 2023 I'm looking at object variable 44 all day. Totally missed the possibility of 43. Just when I thought I was getting better at searching the Function Reference. 1 Quote Link to comment
michaelk Posted October 30, 2023 Share Posted October 30, 2023 Pretty impressive job of sleuthing, Pat. Quote Link to comment
Sam Jones Posted October 30, 2023 Author Share Posted October 30, 2023 (edited) Additionally, I missed using ResetObject on the dimension before ending the PIO code with ResetObject or ResetBBox. As you said, mandatory. Didn't think of it. Probably needed in other object in object scenarios. Edited October 30, 2023 by Sam Jones Addition Quote Link to comment
Pat Stanford Posted October 30, 2023 Share Posted October 30, 2023 Glad to help. Quote Link to comment
Pat Stanford Posted October 30, 2023 Share Posted October 30, 2023 Update: The TextOffset actually appears to be a percentage of the line length instead of something in Page units. I have files a bug against the documentation and noted this in the Dev site version of the Function Reference. 2 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.