Steven Morgan Posted April 20, 2023 Share Posted April 20, 2023 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. Quote Link to comment
Jesse Cogswell Posted April 21, 2023 Share Posted April 21, 2023 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: Pick Object dragged on top of 1st Electric Hanging Position On drag release, Pick Object pulls name of the Hanging Position and resets Pick Test.vso 1 Quote Link to comment
Steven Morgan Posted April 24, 2023 Author Share Posted April 24, 2023 Absolutely brilliant answer @Jesse Cogswell, worked great. THank you Quote Link to comment
Recommended Posts
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.