Sam Jones Posted May 12, 2023 Share Posted May 12, 2023 If I can get the name of a Light Position Obj (LPO)(Hanging Position), how can I get a handle to the LPO. Is the only option to cycle through all the LPOs until I find a match using a "ForEachObject() and GetRField(LPO, 'Light Position Obj', 'Position Name')? GetObject(name) won't work, because the name is not put in the "Name" field at the bottom of the LPO instance's OIP. Quote Link to comment
Pat Stanford Posted May 12, 2023 Share Posted May 12, 2023 How about ForEachObject with a Callback Procedure that just returns the handle and a criteria of the Position Name? I can probably explain that better if it is not clear enough. Quote Link to comment
Sam Jones Posted May 12, 2023 Author Share Posted May 12, 2023 1 minute ago, Pat Stanford said: How about ForEachObject with a Callback Procedure that just returns the handle and a criteria of the Position Name? I can probably explain that better if it is not clear enough. Thanks Pat. Not clear enough; go for it. Quote Link to comment
Pat Stanford Posted May 12, 2023 Share Posted May 12, 2023 Typed in the forum and not tested, but you should get the idea. Procedure Test; Var HandleToLPO :Handle; Procedure Execute(Hd1:Handle); Begin HandleToLPO:=Hd1; End; Begin ForEachObject(Execute,('LightPosition Obj'.'Position Name'='YourLPONameHere')); Message('The Handle to the LPO is: ',HandleToLPO); End; Run(Test); Quote Link to comment
Pat Stanford Posted May 12, 2023 Share Posted May 12, 2023 If the Position Name is not unique and you only want the first occurrence you could use FEO In Layer/In List instead and return TRUE from the function to stop after the first object executes. Quote Link to comment
Sam Jones Posted May 12, 2023 Author Share Posted May 12, 2023 Using " 'LightPosition Obj'.'Position Name'='YourLPONameHere' " as a criteria is new and exciting. I was expecting to have to use a selection criteria like " ((R IN ['AP Light Position Obj'])) ". I can simplify many things by specifying record field values in the callback. Off to test now. 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.