.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Selecting objects

1 REPLY 1
Reply
Message 1 of 2
Gaituuth
327 Views, 1 Reply

Selecting objects

Hi

 

I'm busy converting a Vba application to .Net (actually rewriting)

Now I'm running into the following issue

 

I want to select all the objects in the drawing and then based on the linetype it should be moved to a specific layer.

 

I can do this per type (circle, line, etc) but that will be a hell of a job and a lot of code. In Vba I check inside the selection on linetype and then change it to the correct layer. But in .NET i don't figured out a way how to do it.

 

Anybody who can give me advice how to approach this hurdle??

 

Regards,

 

Gerald

 

1 REPLY 1
Message 2 of 2
Alfred.NESWADBA
in reply to: Gaituuth

Hi,

 

hardcoded to linetype "DASHED" and only selected objects that have set the linetype-property directly; so missing in this example are objects, that:

- are within blockdefinitions/-references

- have assigned the linetype "byLayer" and the layer has linetype "DASHED"

 

HTH, - alfred -

 

   <Autodesk.AutoCAD.Runtime.CommandMethod("ISH_Tutorial_SelSetFilterSample")> _
   Public Shared Sub ISH_Tutorial_SelSetFilterSample()
      Dim tAcadDoc As ApplicationServices.Document = ApplicationServices.Application.DocumentManager.MdiActiveDocument
      Dim tTrAct As DatabaseServices.Transaction = Nothing
      Try
         'create a filter for selection
         Dim tSelFilterValues() As DatabaseServices.TypedValue =
            {New DatabaseServices.TypedValue(DatabaseServices.DxfCode.LinetypeName, "DASHED")} 'select by linetype-name
         Dim tSelFilter As EditorInput.SelectionFilter = New EditorInput.SelectionFilter(tSelFilterValues)

         'select through the hole db
         Dim tSelRes As EditorInput.PromptSelectionResult = tAcadDoc.Editor.SelectAll(tSelFilter)
         If (tSelRes IsNot Nothing) AndAlso _
            (tSelRes.Status = EditorInput.PromptStatus.OK) AndAlso _
            (tSelRes.Value IsNot Nothing) AndAlso _
            (tSelRes.Value.Count > 0) Then

            tTrAct = tAcadDoc.TransactionManager.StartTransaction
            For Each tObjID As DatabaseServices.ObjectId In tSelRes.Value.GetObjectIds
               'here you can go through the returned ObjectID's
            Next
         Else
            tAcadDoc.Editor.WriteMessage("No valid object-selection" & vbNewLine)
         End If

      Catch ex As Exception
         Call MsgBox("Error occured (position: 'ISH_Tutorial_SelSetFilterSample')" & vbNewLine & ex.Message)
      Finally
         If tTrAct IsNot Nothing Then tTrAct.Dispose() : tTrAct = Nothing
      End Try
   End Sub

 

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost