Jump to content
Developer Wiki and Function Reference Links ×

Editing Symbol Definition


Sam Jones

Recommended Posts

Is it possible to place a Locus, or any other object, in a symbol definition/

I can get a handle to a symbol definition.

I can iterate through the objects in the definition.

I can edit those objects.

 

But, I cannot find a way to place a Locus or any other object inside a symbol definition.   Anybody know how?

 

Link to comment

Once you have used SetParent, then the coordinates of the object are "translated" into the Symbol Def local coordinate system. So just move it to where you need it to be.

 

Procedure Test;

VAR	H1, H2		:Handle;
	B1			:Boolean;

BEGIN
	H1:=GetObject(GetSymName(FSActLayer));
	Locus(0,0);
	H2:=LNewObj;
	B1:=SetParent(H2,H1);
	HMove(H2, 2',2');
End;

Run(Test);

 

If you have the Locus in the relative location of a symbol instance, then get the location of the Locus and the location of the Symbol Instance and calculate the offset between the two and use that to move the locus after you set the parent.

  • Like 1
Link to comment

 @Sam Jones,

   Just remember that the (0,0) point inside a symbol definition is the Symbol's Insertion Point. In Pat's example, and you place the Locus outside the Symbol and want it in the same relative position inside the symbol, move the Locus by MINUS the symbol's insertion point.

 

Try this.

PROCEDURE xxx;
{ Move Locus into a Symbol at the same position as it was outside the symbol. }
{ Place a symbol, place a locus, select both, run script. }
VAR
	Hsym, Hsdef, Hloc :Handle;
	Psym :Point;
BEGIN
	Hsym := FSActLayer;
	Hsdef := GetObject(GetSymName(Hsym));
	Hloc := LSActLayer;
	GetSymLoc(Hsym, Psym.x, Psym.y);
	
	if SetParent(Hloc, Hsdef) then begin		
		HMove(Hloc, -Psym.x, -Psym.y);
		ResetBBox(Hsdef);
		SysBeep;		{ make noise when done }
	end;		{ if }
END;
Run(xxx);

 

   Are you writing code that needs to work if the User Origin is shifted? If so, I could write a lot more on how to manage coordinates between Drawing Layers and Symbol Definition spaces. If you also want your code to work in Rotated Plan View (ugh), I can help you there, too, but you'll need a good night's sleep and a large bottle of Aspirin.

 

Merry Festivus 😉

Raymond

Link to comment

Nope.  Sorry Raymond.  Your example doesn't work either.  I noticed that your code does not place the locus, so I put in code to do so, but the following code does not work.  SetParent() fails without triggering the alert.  I tried the code below without the HMove(), and still no Joy.  SetParent() seems to be the problem.  No locus shows up anywhere in the symbol.

 

The code was run from a text file .vs.

 

PROCEDURE Test;

VAR    SymHdl        :HANDLE;
          SymDefHdl    :HANDLE;
          LocHdl        :HANDLE;
          X, Y        :REAL;

BEGIN
    SymHdl := FSActLayer;
    SymDefHdl := GetObject(GetSymName(SymHdl));
    GetSymLoc(SymHdl, X, Y);
    Locus(X, Y);
    LocHdl := LNewObj;
    IF SetParent(LocHdl,SymDefHdl) THEN
        BEGIN
            HMove(LocHdl, -X, -Y);
            ResetBBox(SymDefHdl);
        END
    ELSE
        AlrtDialog('SetParent Fails');
END;

RUN(Test);

Edited by Sam Jones
Additional info
Link to comment

If you have a Hybrid Symbol and want the Loci to show in the Top/Plan view. you are going to have to set that for it also now that the "2D" portion of symbols is no longer controlled by Screen Plane objects.

 

Look at AddObjectTo2DComponentGroup and Get2DComponent Group in Objects-Custom.  These seem to apply to both Symbols and PIOs.

 

Merry Christmas.

  • Like 1
Link to comment

Hey @Sam Jones,

   What @Pat Stanford said, AND, is your User Origin Shifted? If it is, you also have to remove that distance from the equation.

 

   From your comment, "SetParent() seems to be the problem.", have you verified that you have a handle to the two objects in question? I have never had a problem with SetParent() if the handles are valid and of the correct type. Also, be careful mixing objects of different types – Screen Plan, Layer Plane, and 3D objects. Mixing them will affect their visibility in different views.

 

   You know, you could make this a whole lot easier if you'd post a file with your symbol in it. There's a lot of guessing going on here. I hope you're grading us on a curve.

 

Merry Christmas to All, and to All a good night. 🙂

Link to comment

@Sam Jones I think your code is working, but it's placing the locus inside the 3D component of the symbol.  The way I usually combat this is to force the planar object (such as the locus point) onto the screen plane by using SetObjectVariableBoolean(<object handle>,1160,TRUE).  I understand that the screen plane is considered deprecated, but it is still what Vectorworks uses to differentiate objects in the 2D component compared to the 3D component of a hybrid symbol.  And forcing an object onto the screen plane with this script will not trigger the "Enable Legacy Features" flag to get set.

 

The script below will place a locus inside the given symbol at X: 1", Y: 1" while also correcting for the User Origin being different than the Internal Origin.  Confirmed working in VW2023.

 

PROCEDURE TestLoci;

CONST

	kSymbol = 'Test Symbol';
	kScreenPlane = 1160;

VAR

	hSymbol,hLocus:HANDLE;
	BSB:BOOLEAN;
	Origin:POINT;

BEGIN
	GetOriginInDocUnits(Origin.x,Origin.y);
	hSymbol:=GetObject(kSymbol);
	Locus(1-Origin.x,1-Origin.y);
	
	hLocus:=LNewObj;
	BSB:=SetParent(hLocus,hSymbol);
	SetObjectVariableBoolean(hLocus,kScreenPlane,TRUE);
	ResetObject(hSymbol);	
END;

Run(TestLoci);

 

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