<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to Rotate Selected Objects in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-rotate-selected-objects/m-p/5008844#M44155</link>
    <description>&lt;P&gt;I have a window that selects some objects (rectangle and two lines, sometimes just a rectangle).&lt;/P&gt;&lt;P&gt;I have seen code that shows how to rotate a single object, but not really much for multiple objects.&lt;/P&gt;&lt;P&gt;Some things I've seen use a "For Each" to get all of the ObjectIds in the selection set and rotate each one.&amp;nbsp; Can someone show me how to create an ObjectIdCollection from a selection set?&lt;/P&gt;&lt;P&gt;I did this, but it just errors out on the rotation:&lt;/P&gt;&lt;PRE&gt;        ' If the component doesn't rotate or does a complete 180, do not rotate it
        If dblCompRot &amp;lt;&amp;gt; 0 Or dblCompRot &amp;lt;&amp;gt; 180 Then
            Dim myDB As DatabaseServices.Database
            Dim myEd As EditorInput.Editor
            Dim compPSR As EditorInput.PromptSelectionResult
            Dim compSelSet As SelectionSet
            Dim compObjIDs As ObjectIdCollection
            Dim comp As Object

            Dim ssWinX1 As Double, ssWinX2 As Double, ssWinY1 As Double, ssWinY2 As Double, ssWinPt1 As Point3d, ssWinPt2 As Point3d
            myDB = myDWG.Database
            myEd = myDWG.Editor

            ' Select the SMD component using a window
            compCenter = New Geometry.Point3d(compCenterX, compCenterY, 0)
            ssWinX1 = compCenterX - ((dblCompLen / 2) + 0.02)
            ssWinX2 = compCenterX + ((dblCompLen / 2) + 0.02)
            ssWinY1 = compCenterY - ((dblCompWid / 2) + 0.02)
            ssWinY2 = compCenterY + ((dblCompWid / 2) + 0.02)
            ssWinPt1 = New Geometry.Point3d(ssWinX1, ssWinY1, 0)
            ssWinPt2 = New Geometry.Point3d(ssWinX2, ssWinY2, 0)
            compPSR = myEd.SelectWindow(ssWinPt1, ssWinPt2)
            'compSelSet = compPSR.Value

            Try
                'Dim compPSR As PromptSelectionResult = ed.SelectAll
                compSelSet = compPSR.Value
                If compSelSet.Count &amp;gt; 0 Then
                    compObjIDs = New ObjectIdCollection(compSelSet.GetObjectIds)
                    For Each compObjId In compObjIDs
                        comp = compObjId.GetObject(OpenMode.ForWrite)
                        Dim m3d As Matrix3d = Matrix3d.Rotation((dblCompRot * (Math.PI / 180)), Geometry.Vector3d.ZAxis, compCenter)
                        'Dim ent2 As Entity = tr.GetObject(oid, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
                        comp.TransformBy(m3d)
                    Next
                End If
            Catch ex As System.Exception
                MsgBox(ex.ToString)
            End Try
        End If

    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
    <pubDate>Fri, 02 May 2014 22:21:17 GMT</pubDate>
    <dc:creator>mgorecki</dc:creator>
    <dc:date>2014-05-02T22:21:17Z</dc:date>
    <item>
      <title>How to Rotate Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-rotate-selected-objects/m-p/5008844#M44155</link>
      <description>&lt;P&gt;I have a window that selects some objects (rectangle and two lines, sometimes just a rectangle).&lt;/P&gt;&lt;P&gt;I have seen code that shows how to rotate a single object, but not really much for multiple objects.&lt;/P&gt;&lt;P&gt;Some things I've seen use a "For Each" to get all of the ObjectIds in the selection set and rotate each one.&amp;nbsp; Can someone show me how to create an ObjectIdCollection from a selection set?&lt;/P&gt;&lt;P&gt;I did this, but it just errors out on the rotation:&lt;/P&gt;&lt;PRE&gt;        ' If the component doesn't rotate or does a complete 180, do not rotate it
        If dblCompRot &amp;lt;&amp;gt; 0 Or dblCompRot &amp;lt;&amp;gt; 180 Then
            Dim myDB As DatabaseServices.Database
            Dim myEd As EditorInput.Editor
            Dim compPSR As EditorInput.PromptSelectionResult
            Dim compSelSet As SelectionSet
            Dim compObjIDs As ObjectIdCollection
            Dim comp As Object

            Dim ssWinX1 As Double, ssWinX2 As Double, ssWinY1 As Double, ssWinY2 As Double, ssWinPt1 As Point3d, ssWinPt2 As Point3d
            myDB = myDWG.Database
            myEd = myDWG.Editor

            ' Select the SMD component using a window
            compCenter = New Geometry.Point3d(compCenterX, compCenterY, 0)
            ssWinX1 = compCenterX - ((dblCompLen / 2) + 0.02)
            ssWinX2 = compCenterX + ((dblCompLen / 2) + 0.02)
            ssWinY1 = compCenterY - ((dblCompWid / 2) + 0.02)
            ssWinY2 = compCenterY + ((dblCompWid / 2) + 0.02)
            ssWinPt1 = New Geometry.Point3d(ssWinX1, ssWinY1, 0)
            ssWinPt2 = New Geometry.Point3d(ssWinX2, ssWinY2, 0)
            compPSR = myEd.SelectWindow(ssWinPt1, ssWinPt2)
            'compSelSet = compPSR.Value

            Try
                'Dim compPSR As PromptSelectionResult = ed.SelectAll
                compSelSet = compPSR.Value
                If compSelSet.Count &amp;gt; 0 Then
                    compObjIDs = New ObjectIdCollection(compSelSet.GetObjectIds)
                    For Each compObjId In compObjIDs
                        comp = compObjId.GetObject(OpenMode.ForWrite)
                        Dim m3d As Matrix3d = Matrix3d.Rotation((dblCompRot * (Math.PI / 180)), Geometry.Vector3d.ZAxis, compCenter)
                        'Dim ent2 As Entity = tr.GetObject(oid, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
                        comp.TransformBy(m3d)
                    Next
                End If
            Catch ex As System.Exception
                MsgBox(ex.ToString)
            End Try
        End If

    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2014 22:21:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-rotate-selected-objects/m-p/5008844#M44155</guid>
      <dc:creator>mgorecki</dc:creator>
      <dc:date>2014-05-02T22:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to Rotate Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-rotate-selected-objects/m-p/5009300#M44156</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;&amp;gt;&amp;gt; how to create an ObjectIdCollection from a selection set?&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;if tSSet is declared like that:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" color="#000080"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim tSSet As Autodesk.AutoCAD.EditorInput.SelectionSet&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;then you can create an objectidcollection in that way:&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#000080"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim tObjIdColl As ObjectIdCollection = New ObjectIdCollection(tSSet.GetObjectIds)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;HTH, - alfred -&lt;/P&gt;</description>
      <pubDate>Sat, 03 May 2014 09:07:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-rotate-selected-objects/m-p/5009300#M44156</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2014-05-03T09:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to Rotate Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-rotate-selected-objects/m-p/5009760#M44157</link>
      <description>&lt;P&gt;You can try this example as too, cnange entity name to your suit&lt;/P&gt;
&lt;PRE&gt;        &amp;lt;CommandMethod("SelCL")&amp;gt; _
        Public Sub GetObjectIdsFromSelection()
            Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor
            Dim res As PromptSelectionResult
            res = ed.GetSelection
            If res.Status &amp;lt;&amp;gt; PromptStatus.OK Then
                Return
            End If
            Dim sset As SelectionSet = res.Value
            Dim ids As ObjectIdCollection = New ObjectIdCollection()
            For Each id As ObjectId In sset.GetObjectIds()
                ' extract just lines and circles without filter:
                If id.ObjectClass.DxfName = "LINE" Or id.ObjectClass.DxfName = "CIRCLE" Then
                    ids.Add(id)
                End If
            Next
            MsgBox(String.Format("Selected {0} lines and circles", ids.Count))
        End Sub&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 May 2014 16:13:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-rotate-selected-objects/m-p/5009760#M44157</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2014-05-03T16:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to Rotate Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-rotate-selected-objects/m-p/5011756#M44158</link>
      <description>&lt;P&gt;mgorecki Use and try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim compObjIDs as&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;FONT color="#FF6600"&gt;O&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;FONT color="#FF6600"&gt;bjectId()&lt;/FONT&gt;=compSelSet.GetObjectIds()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think this is where the problem happen.&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2014 11:28:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-rotate-selected-objects/m-p/5011756#M44158</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-05-05T11:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to Rotate Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-rotate-selected-objects/m-p/5012424#M44159</link>
      <description>&lt;P&gt;Thank you all for your help.&amp;nbsp; I will give these a try and see what happens.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2014 15:49:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-rotate-selected-objects/m-p/5012424#M44159</guid>
      <dc:creator>mgorecki</dc:creator>
      <dc:date>2014-05-05T15:49:08Z</dc:date>
    </item>
  </channel>
</rss>

