Jump to content
Developer Wiki and Function Reference Links ×

Environment Variables


Gonda

Recommended Posts

Hi All,

So, when working with Python scripts, is there any way to access current states of things? Specifically, I'm working on a tool that will take multiple selected objects, read information from them, compute and then modify the objects. What I'm running into is that it seems that most functions want a handle to an object to do anything useful...I've found I can use a custom selection via criteria; however, I can't find a way to get from a selection based on criteria to object handles.

In a perfect world there would be some object or method (ie vs.CurrentSelection(). ) that would return either a single object handle or a list of multiple object handles...any thoughts and/or am I missing something obvious?

Thanks,

Jon Gonda

Link to comment

In Vectorscript one way would be to get a handle to the first object using FSActLayer and then step through the selected object using NextSObj. You are done when the handle from NextSObj returns NIL.

Be careful using these if your routines modify the objects enough that the handle list might change. This is especially important if you are deleting objects or changing their selection state. Sometimes you need to start at the end of the list and work backwards using PrevSObj.

Link to comment

In addition to ForEachObject(), which steps through objects based on criteria, look at ForEachObjectInList() and ForEachObjectInLayer(), which can get the current selection.

One complication to parsing selected objects, if VW will hold the selection state of objects on inactive layers. You need to specify whether to include these objects or not.

If you're working on Python, you can easily use the FEO calls to load handles into a list and then iterate through the list. You can also use the FEO calls with lambda functions if your modification is simple.

-Josh

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