Jump to content
Developer Wiki and Function Reference Links ×

Get the User Origin in actual Sheetlayer and place a Text there


Recommended Posts

Hello

 

I would like to automate the display of information as text (by importing a script in txt Format, that ist writen in another program, where the Data is stored/managed). 
The text should appear where the "UserOrigin" point was defined in the Sheet-Layer (not Designlayer - that works ans is easy).

 

I would like to call the commands with a script that first queries the "UserOrigin" point (it depends on the file) and then places the corresponding text there.    

I already do this for Design-Layers. However in the Sheet-Layer it does not work for me because I cannot access the "UserOrigin" point. Instead the text is placed at the VectorOrigin point in the Sheet-Layer.

 

So how can I access the UserOrigin point of the current Sheet-Layer? 

 

Thanks for your support.

Best regards


Claudia 

Link to comment

My actual "Workaround" looks lke this:

 

 

PROCEDURE LoadFile;  

 

VAR     
xOriginString, yOriginString, TestText, HName:STRING; 
isSheetLayer:BOOLEAN;     
xOrigin, yOrigin:REAL;     
tempHandle, textHandle, H:HANDLE;    

 

BEGIN;

{$DEBUG}

H:= FLayer; {Handle to active Layer}
HName := GetLName(H);


while (H<>nil) do begin
    if GetSheetLayerUserOrigin(H, xOrigin, yOrigin) then
        xoriginString:= Num2Str(6, xOrigin);
        yoriginString:= Num2Str(6, yOrigin);
        TestText:= Concat('Here is the Origin in Layer: ', GetLName(H), ', x = ', xOriginString, ', y = ', yOriginString);
H := NextObj(H);
HName := GetLName(H);

end;
 

FillPat(0);
FillFore(0,0,0);
FillBack(65535,65535,65535);
PenBack(65535,65535,65535);
TextFont(GetFontID('Arial'));
TextSize(12);
TextFace([]);
TextFlip(0);
TextRotate(0);
TextSpace(2);
TextJust(1);
TextVerticalAlign(1);


TextOrigin(xOrigin, yOrigin);

BeginText;
TestText
EndText;

tempHandle := LNewObj;
SetPenFore(tempHandle,65535,0,0 );

 

  END;
  Run(LoadFile);
 

 

Link to comment

I was incorrect. There is a User Origin for each sheet layer. But it is probably not the same as the User Origin that is shared between the design layers.

 

You can access this in a script using the following function:

 

FUNCTION   GetSheetLayerUserOrigin
(	 	layerHandle	:HANDLE;
 	VAR 	xOrigin	:REAL;
 	VAR 	yOrigin	:REAL
) :BOOLEAN ;

 

Link to comment
On 1/24/2025 at 6:29 PM, Pat Stanford said:
FUNCTION   GetSheetLayerUserOrigin
(	 	layerHandle	:HANDLE;
 	VAR 	xOrigin	:REAL;
 	VAR 	yOrigin	:REAL
) :BOOLEAN ;

 

Hi Pat

 

Thank you for your answer. 
When I apply the function GetSheetLayerUserOrigin, I get an x and y value for the design layer at the top position even if I am currently in the sheet layer. 
Hence my workaround above. 

 

That is the reason why I iterate through all layers and get the x and y values from the sheet layer. Otherwise I always end up in the design layers.

The workaround works. It's just a bit much script for manoeuvrable output. Not such a nice solution.

 

Best regards
Claudia

 

Link to comment

GetOriginInDocumentUnits and GetSheetLayerUserOrigin both seem to work correctly.

 

Does this script do what you want?

 

Procedure TagAtSLUserOrigin;
{©2025  Pat Stanford - pat@coviana.com}
{licensed under the Boost Software License 1.0}
{https://github.com/boostorg/boost/blob/master/LICENSE_1_0.txt}
{TL/DR Use as you want, attribution for source, No warranty}


VAR		H1, H2	,H3		:HANDLE;
		X1,Y1, UPI, MLS, DLOX, DLOY	:REAL;
		B1				:Boolean;
		
BEGIN
	GetOriginInDocUnits(DLOX, DLOY); {moving onbjects on Sheet Layers requries an offset from the Document User Origin}
	H1:=FLayer;		{Get first layer in document to process all}
	H2:=ActLayer;  {store active layer to reset at end of script}
	While H1<> Nil DO
		BEGIN
			If GetObjectVariableInt(H1, 154)=2 then {ObjVar 154 is Layer Type 1= DL, 2=SlabThickness}
				BEGIN
					Layer(GetLName(H1));  {makes the SL Active Layer}
					B1:=GetSheetLayerUserOrigin(H1, X1,Y1); 

					MoveTo(X1-DLOX, Y1-DLOY); {move to the SL Origin - DL Origin}
					CreateText( Concat('The SL UO is: ', X1, '  ', Y1) );
				End;
			H1:=NextLayer(H1);
		End;
	Layer(GetLName(H2)); {Restore the active layer at the beginning of the script}
End;

Run(TagAtSLUserOrigin);

 

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...