Jump to content
Developer Wiki and Function Reference Links ×

Get Spotlight Position Name with PIO


Recommended Posts

I'm sure the answer is no, but is there anyway to have a PIO get the hanging position name that it is placed on?


Exactly how Spotlight Instruments detect the Hanging Position they're attached to? My exact application is when a custom Truss Tag PIO is placed on a piece of truss I want it to auto fill its Position field.

Link to comment

Very yes.  I've attached a short PIO showing this.  It's a Point Object with a single parameter, a static text parameter called linkedPos.  The PIO is set to Reset on Move (this is very important).

 

The code looks like this:

PROCEDURE PickTest;

VAR

	linkedPos,objName:STRING;
	objHd,recHd,wallHd,pickHd:HANDLE;
	origin:POINT;

BEGIN
	linkedPos:=PlinkedPos;
	
	IF GetCustomObjectInfo(objName,objHd,recHd,wallHd) THEN GetSymLoc(objHd,origin.x,origin.y);
	pickHd:=PickObject(origin.x,origin.y);
	
	IF((pickHd <> NIL) & (GetName(GetRecord(pickHd,NumRecords(pickHd))) = 'Light Position Obj')) THEN
		BEGIN			
			IF(GetRField(pickHd,'Light Position Obj','Position Name') <> linkedPos) THEN
				BEGIN
					linkedPos:=GetRField(pickHd,'Light Position Obj','Position Name');
					SetRField(objHd,GetName(recHd),'linkedPos',linkedPos);
					ResetObject(objHd);
				END;
		END;
	
	Locus(0,0);
	CreateText(linkedPos);
END;

Run(PickTest);

 

It uses GetCustomObjectInfo to get a handle to itself, then GetSymLoc to get it's insertion point.  From there, it uses PickObject to get a handle to the object directly below it.  It uses a quick test to see if the resulting handle is an object that exists and, using a mixture of GetName, GetRecord, and NumRecords to get the object type, if that object is a Light Position Obj (the actual definition name of the Hanging Position object).

 

If those tests are passed, the code then checks the position's name against the linkPos parameter, if they don't match, the code uses SetRField and ResetObject to update the parameter with the new position name.

 

Then it just creates a Locus at the insertion point and creates a text box with the position name.

 

Pick Test Object placed between two Hanging Position objects:

image.thumb.png.ab534922afe81e022b3f9e435b8e5377.png

 

Pick Object dragged on top of 1st Electric Hanging Position

image.thumb.png.125a7c873acc77ebe5eabd3bd5057c89.png

 

On drag release, Pick Object pulls name of the Hanging Position and resets

image.thumb.png.9fa8fe10f78127cb9efd2f36ffee73b9.png

Pick Test.vso

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