Jump to content
Sign in to follow this  
PeterT

Isolating objects in a script

Recommended Posts

If I enter a group during a script using "DoMenuTextByName('Group Navigation Chunk', 1);", once inside the group, would any additional calls affect only the objects within the group or would they affect objects outside of the group?

For example, would "SelectAll;" select only objects within the group, or when the group is exited, would all the other objects on the layer(s) be selected?

Is this a good method for isolating objects in order to perform operations on just those objects, or is their a better way of acheiving this?

Thanks for any input,

Peter

Share this post


Link to post

Hi Peter,

There are different ways to work inside groups, but I tried the following code to see what would happen, and you can enter a group and do what you want the way you suggest.

DoMenuTextByName('Group Navigation Chunk', 1);

SelectAll;

I created a group, entered it, deselected everything, then exited. With only the group selected I ran the above code. The objects inside the group are selected. On exiting the group, no other objects beside the group are selected.

Raymond

Share this post


Link to post

I use a number of scripts that work on groups in various ways.

Generally I use selection status to isolate the group or groups to affect, and then step thru the objects within as Patrick suggests.Most of these scripts then use class to decide what to do to each object in the group(s).

This has been a very reliable and efficient approach.I imagine that by name is another way.

HTH

Charles

[ 08-26-2004, 09:18 PM: Message edited by: ccroft ]

Share this post


Link to post

Hi Peter,

Why are you wanting to use the DMTBN call? If you want to work on objects within a group then get a handle to the group you want and use FInGroup() to get to the first object. With that handle you can scroll through the list of objects within using NextObj(). Once it returns NIL then your at then end of the list of objects inside that group.

Does this make sense? I would avoid using DMTBN if there is any other way to do it. If you spell out more clearly what you want to do I may be able to help you further...

Patrick

Share this post


Link to post

Hi All,

Thanks for the replies. I started this thread a while ago, and since got busy with real work (architecture). I never finished my script as I could not resolve some issues, but would still like to finish it when my time frees up.

I know I should not use "DoMenuTextByName" if I can avoid it, but it was the only way I could think of to get around a couple things.

First of all, I am trying to trim some objects with a cutting object like a line. I am not clear on how to "trim" without using the menu command.

Secondly, to trim the objects, I need to have the cutting line selected, and the objects to be trimmed deselected.

I have written my script to select all objects touching a user defined line. To trim them I thought I could group the selected objects, then enter the group, deselect the objects, trim them with my line, exit the group, and ungroup them again.

As these objects may all be on different layers, I am already having to step through my layers and do a separate group/trim/ungroup for each layer.

But at least when I trim, I can trim all the desired objects on each layer with one command. If I step through all the objects in each group, and trim them individually, I might be invoking the trim command a couple of hundred times for each layer.

Next, my script was selecting objects on one side of the line an deleting them, but only those objects that were just trimmed (i.e. only those objects touching the line)

The problem I was having with the script before I stopped working on it was the execution seemed very slow, and it also seemed to select objects nowhere near my cutting line and delete them unintentionally.

I will try to get back into the script soon so I can be a little more specific with the problems it is having.

Regards,

Peter

Share this post


Link to post

Sounds like a interesting script.

How does it differ from just using

the split tool? Part of a larger script?

Using built in tools in the way you

describe is not easy. The selection

state of object can change and the

list of objects shrinks and grows as

you modify the list. I have ended up

in infinite loops using this method.

I would walk through it in a very

methodical way to be sure you are

not trapping yourself.

Patrick

Share this post


Link to post

The trim routine is just a part of a much larger script which relocates the trimmed objects, and draws additional objects, and is all controled by a modern dialog.

I have refined my script to get away from the edit group stuff by using ForEachObjectInLayer instead, and filtering for only selected objects.

I did encounter the infinite loop problem you are talking about myself, but somehow resolved it.

I am using the ForEachObjectInLayer procedure with a trim function being called. In the trim function, a cutting line is drawn, used to trim an object into two objects, then deleted.

My script seems to work now, but in a file with a lot of objects, it seems to take a long time to execute.

When an object is cut into two, what happens in the document list? Does one of the two pieces retain its place in the list and the other become the newest member of the list?

If that is the case, then would a ForEachObject routine first go through the list of objects originally in the file, then continue through all the newly created objects (ie the second halves of all the trimmed objects)?

If this is true, then none of these new objects need trimming and somehow I need to exit the routine after it is done trimming the original objects before it gets to the new ones.

How would I get the trim function to return "True" to stop the traversal? This would save about 50% ot the trim calls I think.

Peter

Share this post


Link to post

The trim routine is just a part of a much larger script which relocates the trimmed objects, and draws additional objects, and is all controled by a modern dialog.

I have refined my script to get away from the edit group stuff by using ForEachObjectInLayer instead, and filtering for only selected objects.

I did encounter the infinite loop problem you are talking about myself, but somehow resolved it.

I am using the ForEachObjectInLayer procedure with a trim function being called. In the trim function, a cutting line is drawn, used to trim an object into two objects, then deleted.

My script seems to work now, but in a file with a lot of objects, it seems to take a long time to execute.

When an object is cut into two, what happens in the document list? Does one of the two pieces retain its place in the list and the other become the newest member of the list?

If that is the case, then would a ForEachObject routine first go through the list of objects originally in the file, then continue through all the newly created objects (ie the second halves of all the trimmed objects)?

If this is true, then none of these new objects need trimming and somehow I need to exit the routine after it is done trimming the original objects before it gets to the new ones.

How would I get the trim function to return "True" to stop the traversal? This would save about 50% ot the trim calls I think.

Peter

Share this post


Link to post

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.

Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...