- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
A simple task (or so you would think), but I am trying to mirror a group of blocks. When I insert each one I am appending them to a group and then iterating that group to modify certain aspects. One of which is mirroring...
Now when I use the standard mirror command, the attribute values all look right. If I do it programmatically, well, here we are:
I have set the system variable MIRRTEXT to 0, but to no avail. Nothing changes, but my code for whatever reason simply won't work. Is there a simple answer to this or am I required to go through and determine each attribute? If so, how on earth do you make it go back when it technically isn't "backwards"?
Any and all help is appreciated.
<CommandMethod("UDC_ConduitFlip180")> Public Sub UDC_ConduitFlip180()
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("MIRRTEXT", 0)
Using tr As Transaction = doc.TransactionManager.StartTransaction()
Dim UCS As CoordinateSystem3d = ed.CurrentUserCoordinateSystem.CoordinateSystem3d
Dim ulDir As String = String.Empty
Dim peo As New PromptEntityOptions(vbLf & "Select Entity: ")
peo.SetRejectMessage(vbLf & "Must be block reference...")
peo.AddAllowedClass(GetType(BlockReference), True)
Dim per As PromptEntityResult = ed.GetEntity(peo)
If Not per.Status = PromptStatus.OK Then Return
Dim br As BlockReference = CType(tr.GetObject(per.ObjectId, 0), BlockReference)
Dim acBlkTblRec As BlockTableRecord
If br.IsDynamicBlock Then
acBlkTblRec = TryCast(tr.GetObject(br.DynamicBlockTableRecord, OpenMode.ForRead, False, forceOpenOnLockedLayer:=True), BlockTableRecord)
Else
acBlkTblRec = TryCast(tr.GetObject(br.BlockTableRecord, OpenMode.ForRead, False, True), BlockTableRecord)
End If
If acBlkTblRec.IsFromExternalReference = True Or acBlkTblRec.IsLayout = True Then Return
If UCase(acBlkTblRec.Name).EndsWith("R") Then ulDir = "L" Else ulDir = "R"
Dim bName As String = String.Empty
Select Case ulDir
Case "L" : bName = "TRENCH_VIEW-L"
Case "R" : bName = "TRENCH_VIEW-R"
End Select
Dim bRot As Double = br.Rotation
Dim bPos As Point3d = br.Position
' So here is the mirror component, as you can see I find the simple block with text and mirror it back on its own axis no stress, but the attribute blocks all place the text in a bacward style... yet when I click on it, it does not say backward....
For Each id In idCol
Dim oChkEnt = TryCast(tr.GetObject(id, OpenMode.ForWrite), Entity)
oChkEnt.TransformBy(Matrix3d.Mirroring(acLine3d))
If TypeOf oChkEnt Is BlockReference Then
Dim chkbr As BlockReference = CType(tr.GetObject(id, 0), BlockReference)
Dim acPtTo2 As Point3d = Polar(chkbr.Position, chkbr.Rotation + funcGetRads(90), 1)
Dim acLine3d2 As Line3d = New Line3d(chkbr.Position, acPtTo2)
If chkbr.Name.Contains("Comm") Then chkbr.TransformBy(Matrix3d.Mirroring(acLine3d2))
End If
Next
tr.Commit()
End Using
End Sub
Solved! Go to Solution.