CAD software discussion forum > CAD Tutorial & Tips > ZW CAD sample code: edit offset entity

ZW CAD sample code: edit offset entity

Rank: 5Rank: 5


posts: 10

Registered: 2013-7-12

Message 1 of 1

 ZW CAD sample code: edit offset entity
30-07-2013 04:29 . pm | View his/her posts only
ZWCAD+ sample code: edit offset entity. 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 OffsetObject()
Dim ZcDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim ZcDB As Database = ZcDoc.Database
Dim ZcEd As Editor = ZcDoc.Editor
Using ZcTran As Transaction = ZcDB.TransactionManager.StartTransaction()
Dim Ent As Curve
Dim peo As New PromptEntityOptions(vbLf & "Select object:")
peo.SetRejectMessage(vbLf & "Must be curve.")
peo.AddAllowedClass(GetType(Curve), True)

Dim per As PromptEntityResult = ZcEd.GetEntity(peo)
If per.Status <> PromptStatus.OK Then
End If

Ent = DirectCast(ZcTran.GetObject(per.ObjectId, OpenMode.ForWrite), Curve)
Loop While Ent is Nothing

Dim pro1 As New PromptDoubleOptions(vbLf & "Input offset distance:")
Dim proR1 As PromptDoubleResult = ZcEd.GetDouble(pro1)
If proR1.Status <> PromptStatus.OK Then
End If
Dim dist As Double = proR1.Value

Dim curves As List(Of Curve) = New List(Of Curve)()
Dim Coffset As DBObjectCollection = Ent.GetOffsetCurves(dist)

For Each i As Object In Coffset
curves.Add(DirectCast(i, Curve))
Dim ZcBLT As BlockTable = ZcTran.GetObject(ZcDB.BlockTableId, OpenMode.ForRead)
Dim ZcBLTR As BlockTableRecord = ZcTran.GetObject(ZcBLT(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
For Each j As Object In curves
ZcTran.AddNewlyCreatedDBObject(j, True)

End Using
End Sub

End Class

Try ZWCAD+ free for 30 days:
See also