Translate

quarta-feira, 12 de julho de 2023

Manual VB.net para ZWCAD : POLYLINE

 Criação de uma Polilinha, com coordenadas (0,0) , (1,0) , (3,5).




Com programação VB.net

1:  Imports ZwSoft.ZwCAD.ApplicationServices  
2:  Imports ZwSoft.ZwCAD.Runtime  
3:  Imports ZwSoft.ZwCAD.DatabaseServices  
4:  Imports ZwSoft.ZwCAD.Geometry  
5:    
6: Public Class ZWPolylineObject
7:
8:  <CommandMethod("NewPolyline")>
9:  Public Sub NewPolyline()
10:
11:     Dim ZWDoc As Document = Application.DocumentManager.MdiActiveDocument
12:     Dim ZWCurDb As Database = ZWDoc.Database
13:
14:     Using ZWTrans As Transaction = ZWCurDb.TransactionManager.StartTransaction()
15:
16:         Dim ZWBlkTbl As BlockTable = ZWTrans.GetObject(ZWCurDb.BlockTableId, OpenMode.ForRead)
17:         Dim ZWBlkTblRec As BlockTableRecord = ZWTrans.GetObject(ZWBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
18:
19:         Dim ZWPoly As Polyline = New Polyline()
20:         ZWPoly.SetDatabaseDefaults()
21:         ZWPoly.AddVertexAt(0, New Point2d(0, 0), 0, 0, 0)
22:         ZWPoly.AddVertexAt(1, New Point2d(1, 0), 0, 0, 0)
23:         ZWPoly.AddVertexAt(2, New Point2d(3, 5), 0, 0, 0)
24:
25:         ZWBlkTblRec.AppendEntity(ZWPoly)
26:         ZWTrans.AddNewlyCreatedDBObject(ZWPoly, True)
27:
28:         ZWTrans.Commit()
29:     End Using
30: End Sub
31:
32: 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: NewPolyline.





Testem 
Cumprimentos. 

Sem comentários:

Enviar um comentário