CAD software discussion forum > CAD Tutorial & Tips > ZW CAD vb.net sample code: edit mirror entity

ZW CAD vb.net sample code: edit mirror entity

Rank: 5Rank: 5

Viola

posts: 10

Registered: 2013-7-12

Message 1 of 1

 ZW CAD vb.net sample code: edit mirror entity
30-07-2013 04:33 . pm | View his/her posts only
ZWCAD+ vb.net sample code: edit mirror 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 MirrorObject()
Dim ZcDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim ZcDB As Database = ZcDoc.Database
Dim ZcEd As Editor = ZcDoc.Editor

Dim peo As New PromptEntityOptions(vbLf & "Select object:")
Dim per As PromptEntityResult = ZcEd.GetEntity(peo)
If per.Status <> PromptStatus.OK Then
Return
End If

Dim pro1 As New PromptPointOptions(vbLf & "Input first point:")
Dim proR1 As PromptPointResult = ZcEd.GetPoint(pro1)
If proR1.Status <> PromptStatus.OK Then
Return
End If
Dim Pt1 As Point3d = proR1.Value


Dim pro2 As New PromptPointOptions(vbLf & "Input second point:")
Dim proR2 As PromptPointResult = ZcEd.GetPoint(pro2)
If proR2.Status <> PromptStatus.OK Then
Return
End If
Dim Pt2 As Point3d = proR2.Value

Dim MLine As Line3d = New Line3d(Pt1, Pt2)
Dim Mt As Matrix3d = Matrix3d.Mirroring(MLine)

Using ZcTran As Transaction = ZcDB.TransactionManager.StartTransaction()
Dim Ent As Entity = ZcTran.GetObject(per.ObjectId, OpenMode.ForWrite)
Ent.TransformBy(Mt)
ZcTran.Commit()
End Using
End Sub

End Class




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