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
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