Jump to content

Script doesn't run while in EdiGroup or in Edit Wiewport Annotation


AlbertoB

Recommended Posts

I've just discovered that they doesn't work only in which scripts where I've used

FSActlayer function

to get an handle to the first object selected in the active layer.

I often use this method: select an object (line, arc, text etc.) to get some information to draw another entity. FsActlayer works fine but not in "Edit Group" mode.

P.S.: Other scripts work.

Link to comment

You are right. And there is not a really easy work around.

The traditional test to determine where you are working (Design Layer, Group, Annotation) is to insert a locus point, GetParent of the locus, get the type of the parent object and delete the locus

If the parent is a group, then you need to use GetVPParent to see if it is an annotation or just a group.

If the parent is a group, use FInGroup to get the first object.

If the parent is an annotation, use FInGroup(GetVWGroup(Handle,2)) to get the first annotation.

In either case you then need to check if the first object is selected and if not then use NSelObject to step through until you get the first selected object.

If I get a chance, I may write a function to do this as a single call. In the meantime, here are the test scripts I used to figure this out.

Pat

*********

Procedure Test;

var H1:Handle;

N1:Integer;

Begin

H1:=FSActLayer;

N1:=GetType(FSActLayer);

If N1=11 then

Begin

H1:=FInGroup(H1);

While not Selected(H1) do H1:=NextSObj(H1);

N1:=GetType(H1);

end;

If N1=122 then

Begin

H1:=FInGroup(GetVPGroup(H1,2));

While not Selected(H1) do H1:=NextSObj(H1);

N1:=GetType(H1);

end;

Message(date(2,2),' ',N1,' ',H1);

end;

Run(test);

**********

**********

Procedure Test2;

Var H1,H2,H3:Handle;

Begin

Locus(0,0);

H1:=LNewObj;

H2:=GetParent(H1);

If GetType(H2)=11 then H3:=GetVPGroupParent(H2);

If H3 = Nil then Message(date(2,2),' ',GetType(H2))

else Message(date(2,2),' ',GetType(H3));

DelObject(H1);

end;

Run(Test2);

**********

Link to comment
  • 1 month later...

I have dug out some code I use to check if inside a group or viewport.

Regards

Bill Wood

function checkstatus : BOOLEAN;

Var

objty : INTEGER;

btest : BOOLEAN;

begin

locus(0,0);

objty := gettype(getparent(Lnewobj));

delobject(Lnewobj);

btest := (objty = 31); {Layer}

if NOT btest then alrtdialog('Exit current editing mode first');

checkstatus := btest;

end;

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