PeterT Posted May 4, 2006 Share Posted May 4, 2006 I have written a script which only works if one specific drawing object is selected. To verify that only the desired object is selected I count the selected objects on the active layer and if the count <> 1, it issues a warning that all other selected objects must first be deselected. It does not matter to me if objects inside groups are selected or not, as long as the group itself is not selected. The problem is, even if I deselect all, and the object info palette tells me nothing is selected, if I select my desired object, and run my script, it fails, and gives me the warning message because there are still objects selected inside groups. Using the criteria (SEL= TRUE) detects the objects inside groups. How can I exclude objects inside groups from my count without excluning the groups themselves? Does anyone have an idea? Quote Link to comment
islandmon Posted May 4, 2006 Share Posted May 4, 2006 Have you tried: FUNCTION FSActLayer:HANDLE Quote Link to comment
PeterT Posted May 4, 2006 Author Share Posted May 4, 2006 Thanks for the reply Islandmon. I had not tried that , but I was just trying to avoid using a loop if I could. You got me looking though, and FUNCTION NumSObj( h:HANDLE ) :LONGINT works fine, and does not count the selected objects inside groups. I guess there are things about using criteria that I don't know. The following code finds things inside groups: actlay:= GetLName(ActLayer); countvalue:= Count((L=actlay) & (SEL=TRUE)); Message('countvalue = ',countvalue); This one does not: countvalue:= NumSObj(ActLayer); Message('countvalue = ',countvalue); Don't know why I didn't use NumSObj in the first place. It is shorter anyway. Quote Link to comment
Gregi Posted November 6, 2020 Share Posted November 6, 2020 Old Topic, but I got a "situation" I would like to select the one and only "first selected" object, even if it's in a group or an viewport to change some attributes. The FSActLayer is working fine, as long as i dont want to use it IN group or IN viewport. Any idea? Quote Link to comment
Pat Stanford Posted November 10, 2020 Share Posted November 10, 2020 If you need more information, search for "Waldo" here on the forum. The Waldo (as in Where's Waldo) is a way to determine where you are in a drawing. Place a locus. ("Waldo") Use LNewObject to get a handle to that object GetParent of Waldo. You now have an idea of where you are. GetType of Parent. If GetType is a Group then use FInGroup go get the first object. Check if it is selected. If not then NextSObj will be the one you want. Repeat as necessary with other types of container objects. Use error checking so that you exclude operations on object types you don't handle. Ask again if you need more help. Quote Link to comment
Gregi Posted November 12, 2020 Share Posted November 12, 2020 I guess I got a solution for my situation. This script gets de active Dimension, no matter if in group or in viewport and changes some parameters. It is based on a script on a Template in Switzerland (VSSM-Vorgabe) which did the same, but wasn't working in groups and Viewports. #hölzli 2020-11-07 #vs.PushAttrs() #h=vs.FSActLayer() l = "'"+vs.GetLName(vs.ActLayer())+"'" crit = '((INVIEWPORT & (L=' + l + ') & (VSEL=TRUE) & (T=DIMENSION)))' out_list = [] def Add_Handle(obj): out_list.append(obj) vs.ForEachObject(Add_Handle,crit) for i in range(len(out_list)): t=vs.GetTypeN(out_list[i]) h=out_list[i] if h == None or t != 63 : vs.AlrtDialog('Bitte eine Einzelmass aktivieren') vs.SetPrimaryDim(h,1,0,'(',')',3); vs.SetDimNote(h,''); #vs.SetPrimaryDim(h,1,0,'(',')',3); #vs.SetPenFore(h, (0,0,0)) vs.SetLW(h,0) vs.ResetObject(h) #vs.PopAttrs() 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.