.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Scaling Multiple Objects in .Net

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
992 Views, 3 Replies

Scaling Multiple Objects in .Net

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.

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

using Entity.TransformBy() method, all you have to do is constructing a transform matrix that dealing with scaling
Message 3 of 4
Hallex
in reply to: Anonymous

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
Message 4 of 4
Anonymous
in reply to: Hallex

This is working fine.. 

 

Thank you so much..

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report