Jump to content

AcadBlockReference VBA InsertionPoint Edit


Recommended Posts

Posted

I want to edit the insertion point of multiple block references. I've been trying to edit them using this code:

 

Private Sub FINDMARQBOOKINLAYOUTS()
Dim OBJLAYOUT As AcadLayout
Dim AOBJ As AcadEntity
Dim MARK As AcadBlockReference
Dim INSSTR As String
Dim ATTDATE As String
Dim LAYOUTNAME As String
Dim INSPOINT(0 To 2) As Variant

ThisDrawing.SetVariable "REGENMODE", 0
INSPOINT(0) = -0.125
INSPOINT(1) = -0.125
INSPOINT(2) = 0

For Each OBJLAYOUT In ThisDrawing.Layouts
   If OBJLAYOUT.Name = "Model" Then
   Else
   ThisDrawing.ActiveLayout = OBJLAYOUT
   LAYOUTNAME = OBJLAYOUT.Name
       'COUNT1 = COUNT1 + 1 ' THIS IS JUST FOR VERIFICATION
       'START BLOCK ITERATION
       For Each AOBJ In ThisDrawing.ActiveLayout.Block
           If TypeOf AOBJ Is AcadBlockReference Then
               If AOBJ.Name = "MARQ-BOOK" Then
                   Set MARK = AOBJ
                   MARK.InsertionPoint(0) = INSPOINT(0)
                   MARK.InsertionPoint(1) = INSPOINT(1)
                   MARK.InsertionPoint(2) = INSPOINT(2)
                   INSSTR = INSSTR & "(" & MARK.InsertionPoint(1) & "," & MARK.InsertionPoint(1) & "," & MARK.InsertionPoint(2) & ")"
               End If
           End If
       Next AOBJ
   End If
Next OBJLAYOUT
ThisDrawing.SetVariable "REGENMODE", 1
MsgBox INSSTR
Unload Me
End Sub

 

This macro iterates the Layouts, finds an specific block reference and then my attempt is to change its insertion point property, but i haven't been able to do it. I know i'm missing something, but can't find what. I'd appreciate some help on this.

Posted

I modified you’re a routine a bit, for testing purposes. See if this works any better.

 

Sub FINDMARQBOOKINLAYOUTS()
Dim OBJLAYOUT As AcadLayout
Dim AOBJ As AcadEntity
Dim MARK As AcadBlockReference
Dim INSSTR As String
Dim ATTDATE As String
Dim LAYOUTNAME As String
Dim INSPOINT(0 To 2) As Double 'Dim as double array

ThisDrawing.SetVariable "REGENMODE", 0
INSPOINT(0) = -0.125
INSPOINT(1) = -0.125
INSPOINT(2) = 0

For Each OBJLAYOUT In ThisDrawing.Layouts
   If OBJLAYOUT.Name <> "Model" Then
     ThisDrawing.ActiveLayout = OBJLAYOUT
     LAYOUTNAME = OBJLAYOUT.Name
       'COUNT1 = COUNT1 + 1 ' THIS IS JUST FOR VERIFICATION
       'START BLOCK ITERATION
       For Each AOBJ In ThisDrawing.ActiveLayout.Block
           If TypeOf AOBJ Is AcadBlockReference Then
               If AOBJ.Name = "MARQ-BOOK" Then
                   Set MARK = AOBJ
                   MARK.InsertionPoint = INSPOINT 'reset insertion point
                   INSSTR = INSSTR & "(" & MARK.InsertionPoint(1) & "," & MARK.InsertionPoint(1) & "," & MARK.InsertionPoint(2) & ")"
               End If
           End If
       Next AOBJ
   End If
Next OBJLAYOUT
ThisDrawing.SetVariable "REGENMODE", 1
MsgBox INSSTR

End Sub

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...