cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically select drawing items by layer and move them.

Pioneer
Pioneer

Is it possible to programatically select all items on a certain drawing layer (256 for example) and move them to a different location on a drawing? If so, could you please provide a code snippet showing that?

 

I am using NX 8.5 and VB.Net

 

Thanks

6 REPLIES

Re: Programatically select drawing items by layer and move them.

Siemens Phenom Siemens Phenom
Siemens Phenom

 

Well, it is easy enough to grab everything on that layer:

 

Dim objects() As NXObject = workPart.Layers.GetAllObjectsOnLayer(256)

 

When you move them, do you just want to translate all of them by some X and Y delta value?

Re: Programatically select drawing items by layer and move them.

Pioneer
Pioneer

Yes Steve that is correct. I want to select all objects on  layer 256 and then move them in the X direction.

 

Regards,

Scott

Re: Programatically select drawing items by layer and move them.

Siemens Phenom Siemens Phenom
Siemens Phenom

 

Scott,

 

Will there be objects in the file that live on layer 256 that do not appear on the drawing?

 

If so we might need to obtain them differently.

 

Thanks,

 

Steve

 

Re: Programatically select drawing items by layer and move them.

Pioneer
Pioneer

Steve, there could be the possibility of objects living on layer 256 that are shown on a different sheet. For instance our titleblock is on layer 256 and will be used on other sheets if necessary but the objects will always be visible on those sheets.

 

Regards,

Scott

Re: Programatically select drawing items by layer and move them.

Siemens Phenom Siemens Phenom
Siemens Phenom

 

Scott,

 

Please try the attached.  I only tested it with a part that had a few notes on the drawing that were on the target layer, so be sure it actually does what you wanted before you save any parts after running it.

 

Based on our earlier conversation, I had it ask for the current drawing, then find all visible objects on the drawing, then ask each one whether it was on the target layer, and if so, I put it in a special list.

 

Part of the code was from a recorded Journal, so you might find that there are some repeated lines or some others that are not strictly necessary.  But I hope it is at least a good start.

 

Regards,

 

Steve

 

Re: Programatically select drawing items by layer and move them.

Pioneer
Pioneer
Hey Steve, I believe this will do the trick. Thanks so much for your help.

Regards,
Scott