Posts: 15
Registered: ‎11-26-2013
Message 1 of 4 (158 Views)
Accepted Solution

Scaling Multiple Objects in .Net

158 Views, 3 Replies
03-28-2014 10:29 PM

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.

Valued Contributor
Posts: 61
Registered: ‎11-19-2010
Message 2 of 4 (134 Views)

Re: Scaling Multiple Objects in .Net

03-29-2014 12:25 AM in reply to: Giri_kani
using Entity.TransformBy() method, all you have to do is constructing a transform matrix that dealing with scaling
*Expert Elite*
Posts: 1,569
Registered: ‎10-08-2008
Message 3 of 4 (136 Views)

Re: Scaling Multiple Objects in .Net

03-29-2014 12:33 AM in reply to: Giri_kani

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
            End If

            Dim pc As Point3d = ppr.Value
                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()

                        Dim ids As ObjectIdCollection = New ObjectIdCollection
                        For Each id As ObjectId In idArr

                        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))

                    End Using
                End Using
            Catch ex As Autodesk.AutoCAD.Runtime.Exception
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(ex.Message & vbLf & ex.StackTrace)
            End Try
        End Sub


Posts: 15
Registered: ‎11-26-2013
Message 4 of 4 (86 Views)

Re: Scaling Multiple Objects in .Net

04-02-2014 12:48 AM in reply to: Hallex

This is working fine.. 


Thank you so much..

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.