Jump to content

Match Rotation of symbol


Recommended Posts

I was hoping to be able to select a number of symbols. Run a script which would prompt me to select another target symbol and all the symbols would rotate to the same orientation of that target symbol.

I would like to use it to place a house symbol on a street then place other houses on the same street and the quickly rotate them to the same angle.

Link to comment
  • 6 years later...

I am having the same problem here as the OP was. Pat's script example is fantastic and is almost 100% of what I'm looking for.

Just trying to replace that dialog with the ability to select a target object (symbol, truss, lighting device, line) and obtain the rotation angle from that.

I think this might be in the right direction:

GetCustomObjectInfo(name,handle,record,wall);

GetSymRot(handle);

As I've very new to VS I'm wondering if anyone might have any example scripts of scripts that have a target selection action as part of them. Hoping I can then reverse engineer that bit and plug it in instead of Pat's dialog.

Link to comment

Figured it out!

A big thanks to Pat Stanford whose scripts provided the basis for my franken-script. This was the first time I've really coded much with variables in a decade. Fun stuff!

Procedure SetLightParams;


Var	ThisLight,PickTarget: Handle;
R2,X2,Y2,Z2 :Real;

FUNCTION CheckObjCallback(h : HANDLE) : BOOLEAN;
 {or FUNCTION CheckObjCallback(h : HANDLE; px, py : REAL) : BOOLEAN;}
 {or FUNCTION CheckObjCallback(h : HANDLE; px, py, pz : REAL) : BOOLEAN;}
 BEGIN
    {any object is ok}
    CheckObjCallback := TRUE;
 END;


Procedure ActOn(ThisObject:Handle); {ThisObject is a handle to the object passes by ForEachObject}

Var X1,Y1,R1 : Real;
	Begin

		{Get the current rotation of the object. GetSymRot works on PIOs as well as symbols}
		R1:=GetSymRot(ThisObject);

		{Get the current location of the object. GetSymLoc also works with PIOs as well as symbols}
		GetSymLoc(ThisObject,X1,Y1);

		{Set Rotation to Zero by rotating the negative of the current value}
		HRotate(ThisObject,X1,Y1,-R1+R2);


	End;

Begin

TrackObject( CheckObjCallback, PickTarget, x2, y2, z2 );

IF PickTarget <> NIL THEN BEGIN

	ForEachObject(ActOn,((SEL=TRUE)));   {ForEachObject will run the procedure named ActON one for each Lighting Device of type Light}
End;

End;

Run(SetLightParams);

Link to comment
  • 2 weeks later...

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