Message 1 of 8
Moving Blocks on the Fly

Not applicable
02-03-2009
10:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am attempting to move a block inside model space using VBA. I know the name of the block
so it can be hard coded into the function, and I can locate the block, but when I go to use the
.move command things get difficult. Eventaully I would like to have the code sellect several
blocks at the same time and allow the user to select "Point2" on the fly similar to what happens
when you use the move command from AutoCAD
Private Sub CommandButton3_Click()
Dim oBlock As AcadBlock
Dim oBlocks As AcadBlocks
Dim BlockName As String
Dim Point1(0 To 2) As Double
Dim Point2(0 To 2) As Double
BlockName = "EPF 245 CL2 ARR3 TOP 1"
Point1(0) = 0: Point1(1) = 0: Point1(2) = 0
Point1(0) = 100: Point1(1) = 100: Point1(2) = 0
Set oBlocks = ThisDrawing.Blocks
For Each oBlock In oBlocks
If oBlock.Name = BlockName Then
oBlock.Move Point1, Point2
End If
Next
End Sub
As always any help would be greatly appreciated!
I am attempting to move a block inside model space using VBA. I know the name of the block
so it can be hard coded into the function, and I can locate the block, but when I go to use the
.move command things get difficult. Eventaully I would like to have the code sellect several
blocks at the same time and allow the user to select "Point2" on the fly similar to what happens
when you use the move command from AutoCAD
Private Sub CommandButton3_Click()
Dim oBlock As AcadBlock
Dim oBlocks As AcadBlocks
Dim BlockName As String
Dim Point1(0 To 2) As Double
Dim Point2(0 To 2) As Double
BlockName = "EPF 245 CL2 ARR3 TOP 1"
Point1(0) = 0: Point1(1) = 0: Point1(2) = 0
Point1(0) = 100: Point1(1) = 100: Point1(2) = 0
Set oBlocks = ThisDrawing.Blocks
For Each oBlock In oBlocks
If oBlock.Name = BlockName Then
oBlock.Move Point1, Point2
End If
Next
End Sub
As always any help would be greatly appreciated!