Jump to content
Developer Wiki and Function Reference Links ×

More VS dimension formatting


Sam Jones

Recommended Posts

Good question.

 

It certainly doesn't look like textFlag does what I expect it to do.

 

From the appendix:

image.png.25d585db8747c6dfc4ff5afec2dc2a15.png

 

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);

 

 

 

 

Link to comment

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.

Link to comment

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.

Link to comment

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.

 

  • Like 1
  • Laugh 1
Link to comment

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);

 

  • Like 1
  • Love 1
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...