CAD/CAM discussion forum > CAD Tutorial & Tips > ZW CAD vb.net sample code: create Aligned dimension entity

ZW CAD vb.net sample code: create Aligned dimension entity

Rank: 5Rank: 5

Viola

posts: 10

Registered: 2013-7-12

Message 1 of 1

 ZW CAD vb.net sample code: create Aligned dimension entity
30-07-2013 04:26 . pm | View his/her posts only
ZWCAD+ vb.net sample code: create Aligned dimension entity.
vb.net sample codes:

Imports ZwSoft.ZwCAD.Runtime
Imports ZwSoft.ZwCAD.ApplicationServices
Imports ZwSoft.ZwCAD.DatabaseServices
Imports ZwSoft.ZwCAD.EditorInput
Imports ZwSoft.ZwCAD.Geometry

Public Class ZwcadApps

_
Public Sub CreateAlignD()
Dim ZcDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim ZcDB As Database = ZcDoc.Database
Dim ZcEd As Editor = ZcDoc.Editor

Dim peo1 As New PromptPointOptions(vbLf & "Specify first extension line origin:")
Dim per1 As PromptPointResult = ZcEd.GetPoint(peo1)
If per1.Status <> PromptStatus.OK Then
Return
End If
Dim pt1 As Point3d = per1.Value

Dim peo2 As New PromptPointOptions(vbLf & "Specify second extension line origin:")
Dim per2 As PromptPointResult = ZcEd.GetPoint(peo2)
If per2.Status <> PromptStatus.OK Then
Return
End If
Dim pt2 As Point3d = per2.Value

Dim peo3 As New PromptPointOptions(vbLf & "Specify point:")
Dim per3 As PromptPointResult = ZcEd.GetPoint(peo3)
If per3.Status <> PromptStatus.OK Then
Return
End If
Dim pt3 As Point3d = per3.Value

Dim styleID As ObjectId = ZcDB.Dimstyle
Dim ent As AlignedDimension = New AlignedDimension(pt1, pt2, pt3, "<>", styleID)

Using ZcTran As Transaction = ZcDB.TransactionManager.StartTransaction()
Dim ZcBLT As BlockTable = ZcTran.GetObject(ZcDB.BlockTableId, OpenMode.ForRead)
Dim ZcBLTR As BlockTableRecord = ZcTran.GetObject(ZcBLT(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

ZcBLTR.AppendEntity(ent)
ZcTran.AddNewlyCreatedDBObject(ent, True)

ZcTran.Commit()
End Using
End Sub

End Class



Try ZWCAD+ free for 30 days:
http://www.zwsoft.com/zwcad+/
See also