.NET

Reply
Contributor
Giri_kani
Posts: 15
Registered: ‎11-26-2013
Message 1 of 4 (144 Views)
Accepted Solution

Scaling Multiple Objects in .Net

144 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
cdinten
Posts: 61
Registered: ‎11-19-2010
Message 2 of 4 (120 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*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 3 of 4 (122 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
                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

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Contributor
Giri_kani
Posts: 15
Registered: ‎11-26-2013
Message 4 of 4 (72 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..

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
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 to get help installing your software.

Ask the Community