Jump to content

Acquiring handle to object in Viewport annotation mode? VW2013


LarryO

Recommended Posts

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.

Link to comment

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.

Link to comment
  • 3 weeks later...

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);

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