Discuss and ask questions about CAD .NET library.
Moderators: SDS, support, admin
-
fury
- Posts: 10
- Joined: 29 Jan 2008, 18:34
Post
by fury » 14 Feb 2008, 20:00
I would like to be able to identify all entities in a layer once any entity in that layer is selected.
I've tried:
Code: Select all
Dim Selected As SortedList = CADImage.SelectedEntities
Dim tmpKey As String
Dim Line As CADImport.CADEntity
For Each tmpKey In Selected.Keys
Line = Selected(tmpKey)
'For i As Integer = 0 To Line.Layer.Entities.AllValues.Length - 1
'Dim cadent As CADEntity = Line.Layer.Entities(i)
'cadent.Selected = True
'Next
'the above For generated an exception because Line.Layer.Entities was nothing.
Next
If Line Is Nothing Then Exit Sub
CADImage.AddEntityToSelectCollection(Line.Layer)
CADImage.DoSelectEntity(Line.Layer)
DWT.CAD.InvalidateImage()
CADImage.InvalidateSelectedEntities(CADPict.CreateGraphics)
Any ideas? Thanks very much!
-
support
- Posts: 3272
- Joined: 30 Mar 2005, 11:36
-
Contact:
Post
by support » 15 Feb 2008, 16:01
Hello!
Please try the following code (it selects all entities on the layer "0"):
Code: Select all
<font color="blue">Private Sub</font id="blue"> btnSelectEntByLayer_Click(<font color="blue">ByVal</font id="blue"> sender <font color="blue">As</font id="blue"> System.Object, <font color="blue">ByVal</font id="blue"> e <font color="blue">As</font id="blue"> System.EventArgs) Handles btnSelectEntByLayer.Click
<font color="blue">Dim</font id="blue"> ent <font color="blue">As</font id="blue"> CADEntity
<font color="blue">Dim</font id="blue"> Cn, I <font color="blue">As Integer
If Me</font id="blue">.cadImage <font color="blue">Is Nothing Then
Return
End If</font id="blue">
Cn = <font color="blue">Me</font id="blue">.cadImage.Converter.Entities.Count
<font color="blue">For</font id="blue"> I = 0 <font color="blue">To</font id="blue"> Cn - 1
ent = <font color="blue">Me</font id="blue">.cadImage.Converter.Entities(I)
<font color="blue">If</font id="blue"> (<font color="blue">Not</font id="blue"> ent.Layer <font color="blue">Is Nothing</font id="blue">) <font color="blue">Then
If</font id="blue"> (ent.Layer.Name = "0") <font color="blue">Then
Me</font id="blue">.cadImage.DoSelectEntity(ent)
<font color="blue">End If
End If
Next
Me</font id="blue">.cadImage.ClearBuffer()
<font color="blue">Me</font id="blue">.cadPictBox.Invalidate()
<font color="blue">End Sub</font id="blue">
Sergey.
Please post questions to the forum or write to
support@cadsofttools.com
-
fury
- Posts: 10
- Joined: 29 Jan 2008, 18:34
Post
by fury » 15 Feb 2008, 18:12
Thanks very much! Works perfectly!