Jump to content

Is possible apply transformd method to a rectangular array of blocks


lewis770227

Recommended Posts

I´m doing a code that created an array of blockRefObject and After that this resulting array I would like to modificate by transform method.

Best regards

Link to comment
Share on other sites

Look this code:

Sub Example_ArrayRectangular()

 

' Create the circle

Dim circleObj As AcadCircle

Dim center(0 To 2) As Double

Dim radius As Double

 

Dim newUCS As AcadUCS

Dim currUCS As AcadUCS

Dim varUCSMatrix As Variant

 

pb = ThisDrawing.Utility.GetPoint(, "basepoint: ")

px = ThisDrawing.Utility.GetPoint(, "xdirection: ")

py = ThisDrawing.Utility.GetPoint(, "ydirection: ")

 

center(0) = 2#: center(1) = 2#: center(2) = 0#

radius = 0.5

Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)

ThisDrawing.Application.ZoomAll

 

' Define the rectangular array

Dim numberOfRows As Long

Dim numberOfColumns As Long

Dim numberOfLevels As Long

Dim distanceBwtnRows As Double

Dim distanceBwtnColumns As Double

Dim distanceBwtnLevels As Double

numberOfRows = 5

numberOfColumns = 5

numberOfLevels = 1

distanceBwtnRows = 1

distanceBwtnColumns = 1

distanceBwtnLevels = 1

 

Set newUCS = ThisDrawing.UserCoordinateSystems.Add(pb, px, py, "TestUCS")

varUCSMatrix = newUCS.GetUCSMatrix

 

' Create the array of objects

Dim retObj As Variant

retObj = circleObj.ArrayRectangular(numberOfRows, numberOfColumns, numberOfLevels, distanceBwtnRows, distanceBwtnColumns, distanceBwtnLevels)

retObj.TransformBy varUCSMatrix

 

ZoomAll

 

End Sub

 

An error ocurrs in line transformBy, beside I don´t know how work distanceBwtnLevels and numberOfLevels in array definition

Link to comment
Share on other sites

The .TransformedBy method is limited to individual entities. You’ll probably have to do something like this:

 

Dim retObj() As AcadEntity
Dim varEnt As Variant
Dim ent As AcadEntity
retObj = circleObj.ArrayRectangular(numberOfRows, numberOfColumns, numberOfLevels, distanceBwtnRows, distanceBwtnColumns, distanceBwtnLevels)

For Each varEnt In retObj
  Set ent = varEnt
  ent.TransformBy varUCSMatrix
Next
circleObj.TransformBy varUCSMatrix

 

You may also find that ThisDrawing.UserCoordinateSystems.Add is pretty finicky about the input coordinates. Additional steps may be required to ensure that the two vectors are perpendicular.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...