Jump to content

using vs.ForEachObject() in a point object not working correctly


Recommended Posts

hey guys,

 

I'm working on a plugin that will behave similarly to the instrument summary but for power. part of that requires the plugin to find all the lighting devices in the drawing and gather information about that. i've done this a few times with menu command based plugins but i want to make it a point object to give a graphical interface like the instrument summary...

 

below is the part of my script that deselects everything and then selects all my lighting devices, loops though them and collects some info about it.  from what i can tell this just flat out doesn't work in a point object plugin... i've tested it in a menu command and works like a dream. it seems to select all the lights, NOT do the for each object, and then NOT deselect anything... 

 

i've also tried using a widget button (with event based turned on) to gather light info and that gives me some other weird results with not redrawing all the 2d elements like text and rectangles correctly.

 

 

cur_lay_opt = vs.GetLayerOptions()
vs.SetLayerOptions(5)

vs.DSelectAll()
vs.SelectObj("(PON='Lighting Device')")
vs.ForEachObject(light_collect, '((VSEL=TRUE))')
vs.DSelectAll()

vs.SetLayerOptions(cur_lay_opt)

 

Link to comment

It is probably not a good design decision to have an object that when reset changes the selection and options of the drawing.

 

Changing selection is the hard way. You would be much better off just using the criteria of PON='Lighting Device' directly in the ForEachObject call. Then you can avoid all of the selecting, selecting, and layer options setting.

 

Have you tried to put something for debugging into the light_collect procedure to make sure it is running? I often use AlrtDialog for this so that I get an dialog box that requires input for each time the procedure runs.

  • Like 1
Link to comment

thanks Pat. i also use AlrtDialog when i need to debug something. it wasn't being triggered when i put it in the light_collect function. maybe the plugin didn't recognize that it had something selected since it was selecting and running at in the same pass? who knows...

 

ANYWAYS... moving the PON='Lighting Device' to the foreach seemed to do the trick. its seeing the lights now. thanks!  

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