Add or Remove elements by layer from select set

Phenom
Phenom

Just wanting to know if its possible to select all elements on a specific layer and either add to or remove them from a select set.

The reason for asking is I want to modify my drawing border placement macro so that I can just replace certain parts of the border - for example the border text, logo or revision tables.

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.
6 REPLIES

Re: Add or Remove elements by layer from select set

Phenom
Phenom

I think this should be possible using the AddAll Method of the SelectSet and then looping through the elements to check the layer.

 

~Tushar Suradkar

www.CADVertex.com

www.SurfAndCode.in

Re: Add or Remove elements by layer from select set

Phenom
Phenom

I've found a soultion that works pretty well.

By temporarily making a layer non-locatable it doesn't get added to the select set, so I do that before the copy, then again before I delete any existing border (not forgetting to ensure all layers are locatable afterwards)

For information though, I'd still like to know if there is an answer to my original question.

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.

Re: Add or Remove elements by layer from select set

Phenom
Phenom

Hi Tushar,

Sorry, I didn't see your post until I posted my own reply.

It's that looping through all elements in the select set and finding their layer that I'm not sure about.

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.

Re: Add or Remove elements by layer from select set

Phenom
Phenom

Hi, Here's the piece of code I tested with:

 

Private Sub Button43_Click(sender As System.Object, e As System.EventArgs) Handles Button43.Click

Dim oApp As SolidEdgeFramework.Application = Marshal.GetActiveObject("SolidEdge.Application")
Dim oDoc As SolidEdgeDraft.DraftDocument = oApp.ActiveDocument Dim oSet As SelectSet = Nothing oSet = oDoc.SelectSet oSet.AddAll() MessageBox.Show(oSet.Count.ToString) Dim o As Object = Nothing For i As Integer = oSet.Count To 1 Step -1 o = oSet.Item(i) If o.Layer.ToUpper <> "LayerName".ToUpper Then oSet.Remove(i) End If Next
MessageBox.Show(oSet.Count.ToString) End Sub

The loop that removes objects from the SelectSet is run in reverse order.

I could filter out all objects whose layer was named "LayerName".

 

What is your real name, if you don't mind ? Smiley Happy

 

~Tushar

 

Re: Add or Remove elements by layer from select set

Phenom
Phenom

Thanks Tushar, I'll give that a try.

I prefer to remain annonymous if you don't mind.

I've been using that name for a good few years - originally on the Eng-Tips forum which I still vist from time-to-time.

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.

Re: Add or Remove elements by layer from select set

Phenom
Phenom

Robot Happy