LarryO Posted February 11, 2015 Share Posted February 11, 2015 Does anyone have a technique for getting the handle to an object which is seen through a viewport and chosen/picked while in annotation mode? Ultimately I wish to extract data from an instance of my PIO when placing a custom PIO annotation tag. BUT first I need to some how capture the handle of that PIO that I am seeing in the viewport. Quote Link to comment
JBenghiat Posted February 17, 2015 Share Posted February 17, 2015 The best method I know for finding a selected object inside a container is "where's waldo:" Locus(0,0); waldo:=LNewObj; oldHan:=PrevSObj(waldo); DelObject(waldo); This also works when creating objects that don't register with LNewObj (though in this case use PrevObj() ) -Josh Quote Link to comment
LarryO Posted February 21, 2015 Author Share Posted February 21, 2015 Thanks Josh, The where am I locus technique was one of the first techniques I needed back in the 90's MiniCad 5 for switching & setting standardized classes to work at the push of a keyboard button. It was very satisfying the first time I used it successfully. What I was having troubles with was inconsistent results when investigating the number of parents while trying to capture the viewport handle. I was initially using a PIO point object for my code because the object I need displays information in a viewport annotation space. A link is required to the measured object in a drawing layer to keep the data current. I was trying to setup that link and place the annotation PIO within the code of that PIO. I am realizing now that I will probably need to use a Tool script to link and place that annotation PIO and then add some code into my measured PIO which will force an update of the annotation PIO whenever the measured PIO's data is changed. Another little fun project for my spare time. Quote Link to comment
LarryO Posted March 9, 2015 Author Share Posted March 9, 2015 Ok, so I have gotten really close here. I have determined the location of the object and cycled through the visible layers of the viewport seeking my PlugInObject. While I have partial success with PickObject, I had hoped to use ForEachObjectAtPoint in case my PIO was inside a group. What I found is that ForEachObjectAtPoint locates part(s) within my PIO but doesn't find PIO itself. Is this a bug? Not sure how to create those fancy HTML boxes that some of you use for inserting your script here. So here goes the old fashioned way. Procedure LocatePoint; VAR VPortGrpH,VPortH,LocusH,TestObjectH,PIOObjH,SearchLayerH:HANDLE; VPOriginX,VPOriginY,VPScale,SelectPtX,SelectPtY,ObjPtX,ObjPtY:REAL; Bool1:BOOLEAN; I1,ObjTypeI,VisibilityI,I2:INTEGER; FUNCTION FirstStairPIO (Objh:HANDLE):BOOLEAN; BEGIN FirstStairPIO:=TRUE; Message(GetTypeN(Objh)); IF (GetTypeN(Objh) = 86) THEN BEGIN Message(GetSymName(Objh),'x'); IF ('_StairOutline'=GetSymName(Objh)) THEN BEGIN DSelectAll; SetSelect(Objh); FirstStairPIO:=FALSE; END; END; END; BEGIN ObjPtY:=0.0;ObjPtX:=0.0; SelectPtX:=0.0;SelectPtY:=0.0; ObjTypeI:=0; VPScale:=1; {Where am I?} Locus(0,0); TestObjectH:=LNewObj; LocusH:=TestObjectH; IF TestObjectH≠NIL THEN WHILE NOT((GetTypeN(TestObjectH)=11)|(GetTypeN(TestObjectH)=0)) DO TestObjectH:=GetParent(TestObjectH); VPortGrpH:=TestObjectH; VportH:=GetVPGroupParent(VPortGrpH); ObjTypeI:=GetTypeN(VPortH); VPOriginX:=GetObjectVariableReal(VPortH, 1024); VPOriginY:=GetObjectVariableReal(VPortH, 1025); VPScale:=GetObjectVariableReal(VPortH, 1003); DelObject(LocusH); {SetTempToolHelpStr('Select stair.');} VSave('TempVPsave'); {Save user's environment} GetPt(SelectPtX,SelectPtY); {Inquire user for location of StairPIO} ObjPtX:=SelectPtX-(VPOriginX*VPScale); {adjust location for scale of viewport} ObjPtY:=SelectPtY-(VPOriginY*VPScale); DoMenuTextByName('Group Navigation Chunk',2); {Exit Viewport edit mode} {Search for object on viewport's visible layers} PIOObjh:=NIL;I1:=NumLayers; SearchLayerH:=FLayer; WHILE (I1>0) and (PIOObjh=NIL) DO BEGIN {cycle through layers but stops when an object is found} I1:=I1-1; IF NOT(2=GetObjectVariableInt(SearchLayerH,154)) THEN BEGIN {Ignore sheet layers, this step may not be req'd} Bool1:=GetVPLayerVisibility(VportH,SearchLayerH,VisibilityI); IF 0=VisibilityI THEN BEGIN Layer(GetLName(SearchLayerH)); ForEachObjectAtPoint(FirstStairPIO,1,0,ObjPtX,ObjPtY,1.0); PIOObjh:=LSActLayer; {PIOObjh:=PickObject(ObjPtX,ObjPtY);} END; END; SearchLayerH:=NextLayer(SearchLayerH); END; {Message(ObjTypeI,'x',ObjPtX,'x',ObjPtY,'x',GetLName(SearchLayerH));} IF PIOObjh≠NIL THEN DelObject(PIOObjh); VRestore('TempVPsave'); {Return user to his environment} VDelete('TempVPsave'); END; RUN(LocatePoint); 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.