Jump to content

Handle to selected object in a wall


Recommended Posts

I'm trying to get a handle to a selected object in a wall.

 

When I select a PIO object in a wall (in this case a pilaster) and I run this script:

def apply_code_to_objects(hObj):
    vs.AlrtDialog(f"Obj: {vs.GetTypeN(hObj)} in {vs.GetTypeN(vs.GetParent(hObj))}")


vs.ForEachObject(apply_code_to_objects, "(INSYMBOL & INOBJECT & NOTINDLVP & NOTINREFDLVP & (VSEL=TRUE))")

I get "Obj: 68 in 31", where 68 is wall and 31 is a design layer.

 

I can't find a way to get a handle to the selected pilaster though...

 

Any ideas?

Link to comment

you'd have to do a deep search, for objects within the wall:

try this:

 

def apply_code_to_objects(hObj):
    object_type = vs.GetTypeN(hObj)
    object_parent_type = vs.GetTypeN(vs.GetParent(hObj))
    
    if object_type == 68: # Check if object is a wall, search within wall
        h2 = vs.FIn3D(hObj) # Get handle to first object within the wall object using FIn3D
        while h2 != None:
            if vs.Selected(h2): # If object within is selected
                if vs.GetTypeN(h2) in [86]: #If type is plugin object (86 = Plugin Object) 
                    object_type = vs.GetTypeN(h2) # store object_type as vs.GetTypeN of this selected object within the wall
                    break # break while loop
            h2 = vs.NextObj(h2) # else move onto next object within wall
    
    vs.AlrtDialog(f"Obj: {object_type} in {object_parent_type}")

vs.ForEachObject(apply_code_to_objects, "(INSYMBOL & INOBJECT & NOTINDLVP & NOTINREFDLVP & (VSEL=TRUE))")

 

  • Like 3
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...