Community
I have a objectid collection, I need to scale all tha objects as the scale factor 20.
The object id collection have line,text,block and so on.
How to scale those objects using .net?
Please guide me.
Solved! Go to Solution.
Solved by Hallex. Go to Solution.
Try this example borrowed from Jeff_H
''borrowed from Jeff_H <CommandMethod("Sc20", CommandFlags.UsePickSet And CommandFlags.Redraw)> _ Public Shared Sub ScaleObjects() Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument Dim ed As Editor = doc.Editor Dim db As Database = doc.Database Dim ppo As New PromptPointOptions("") ppo.Message = vbLf & "Pick a center of scaling : " ppo.AllowNone = False Dim ppr As PromptPointResult ppr = ed.GetPoint(ppo) If ppr.Status <> PromptStatus.OK Then Return End If Dim pc As Point3d = ppr.Value Try Using doclock As DocumentLock = doc.LockDocument() Using tr As Transaction = doc.TransactionManager.StartTransaction() Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead), BlockTableRecord) Dim pso As New PromptSelectionOptions pso.MessageForRemoval = vbLf & "Nothing sdelected, try again." pso.MessageForAdding = vbLf & "Select Objects to scale: " pso.RejectObjectsOnLockedLayers = True pso.RejectObjectsFromNonCurrentSpace = True Dim res As PromptSelectionResult = ed.GetSelection(pso) If res.Status <> PromptStatus.OK Then Return Dim idArr() As ObjectId = res.Value.GetObjectIds() btr.UpgradeOpen() Dim ids As ObjectIdCollection = New ObjectIdCollection For Each id As ObjectId In idArr ids.Add(id) Next For Each id In ids Dim ent As Entity = TryCast(tr.GetObject(id, OpenMode.ForRead, False), Entity) If ent Is Nothing Then Return If Not ent.IsWriteEnabled Then ent.UpgradeOpen() ent.TransformBy(Matrix3d.Scaling(20.0, pc)) Next tr.Commit() End Using End Using Catch ex As Autodesk.AutoCAD.Runtime.Exception Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(ex.Message & vbLf & ex.StackTrace) Finally End Try End Sub
Can't find what you're looking for? Ask the community or share your knowledge.