Hello everyone, I'm trying to rotate a selection set, every section of the code seems to be sorking ok, but at the very end, when I try to rotate all of the drawing, it gives the following error:
"Compile error, Expected Function or variable"
Ay ideas how can I make my code work?
My code looks like this:
Sub Rotation()
Dim pointObj As AcadPoint
Dim location(0 To 2) As Double
location(0) = 0#: location(1) = 0#: location(2) = 0#
Set pointObj = ThisDrawing.ModelSpace.AddPoint(location)
Dim oObj(500) As AcadEntity
Dim oSelSet As AcadSelectionSet
Dim i As Integer
i = 0
Dim Angle As Double
Angle = 90
Dim tSelSet As AcadSelectionSet
On Error Resume Next
Set tSelSet = ThisDrawing.SelectionSets.Add("XX")
If tSelSet Is Nothing Then
Set tSelSet = ThisDrawing.SelectionSets.Item("XX")
tSelSet.Clear
End If
For i = 1 To 500
Set oObj(i) = ThisDrawing.ModelSpace.Item(i)
Next
oSelSet.AddItems (oObj)
For i = 1 To oSelSet.Count
Set oObj(i) = oSelSet.Item(i).Rotate(pointObj, Angle)
Next i
End Sub
Solved! Go to Solution.
Solved by dialunau. Go to Solution.
Solved by norman.yuan. Go to Solution.
I think you are confusing AcadPoint entity with a 3-dimension geometric data for a position/location, which we usually call it "point" to refer a location.
When you call AcadEntity.Rotate() method, the first parameter you passed in is the geometric point, NOT A AcadPoint. That is why you got compiling error: you passed wrong data type.
So, in your case, you do not need to add a AcadPoint entity into the ModelSpace. For the rotation to work, you do
For i = 1 To oSelSet.Count
Set oObj(i) = oSelSet.Item(i).Rotate(location, Angle)
Next i
HTH
Norman Yuan
Can't find what you're looking for? Ask the community or share your knowledge.