Translate

segunda-feira, 25 de setembro de 2023

Manual VB.net para ZWCAD : NEW LAYER WITH LINETYPE

 Criação de de uma nova "Layer" agora com "Linetype"


Temos então o código:
Imports ZwSoft.ZwCAD.ApplicationServices
Imports ZwSoft.ZwCAD.DatabaseServices
Imports ZwSoft.ZwCAD.Runtime
Imports ZwSoft.ZwCAD.EditorInput
Imports ZwSoft.ZwCAD.Colors
Public Class LayerWithLine
    <CommandMethod("NewlayerWithLinetype")> _  
    Public Sub ZWNewlayerWithLinetype()

        Dim ZWDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim ZWEd As Editor = Application.DocumentManager.MdiActiveDocument.Editor
        Dim ZWCurDb As Database = ZWDoc.Database

        Using ZWTrans As Transaction = ZWCurDb.TransactionManager.StartTransaction()

            Dim ZWBlkTblRec As BlockTableRecord = ZWTrans.GetObject(ZWCurDb.CurrentSpaceId, OpenMode.ForWrite)
            Dim ZWLayerTable As LayerTable = ZWTrans.GetObject(ZWCurDb.LayerTableId, OpenMode.ForRead)
            Dim ZwLtTable As LinetypeTable = ZWTrans.GetObject(ZWCurDb.LinetypeTableId, OpenMode.ForRead)

            Dim ZWNewlayer As String = "ZWCad_1"
            Dim ZWZWNewlayer_1 As New LayerTableRecord

            If ZWLayerTable.Has(ZWNewlayer) = False Then
                ZWZWNewlayer_1.Name = ZWNewlayer
                ZWZWNewlayer_1.Color = Color.FromColorIndex(ColorMethod.ByAci, 1)
                ZWZWNewlayer_1.LineWeight = LineWeight.LineWeight009
                ZWLayerTable.UpgradeOpen()
                ZWLayerTable.Add(ZWZWNewlayer_1)
                ZWTrans.AddNewlyCreatedDBObject(ZWZWNewlayer_1, True)
            End If

            Dim LineName As String = "dashdot"
            If ZwLtTable.Has(LineName) = False Then
                ZWCurDb.LoadLineTypeFile(LineName, "Zwcad.lin")
            End If

            If ZwLtTable.Has("dashdot") = True Then
                ZWZWNewlayer_1.UpgradeOpen()
                ZWZWNewlayer_1.LinetypeObjectId = ZwLtTable("dashdot")
            End If

            ZWTrans.Commit()
        End Using
    End Sub
End Class

Após escrever o código, deve-se criar o dll. No  ZWCad, na linha de comando: netload carregar o dll criado. na linha de comando chamamos então o comando criado neste caso: NewlayerWithLinetype.

Vamos lá experimentar.
Cumprimentos. 

Sem comentários:

Enviar um comentário