Jump to content

Error when inserting blocks (VBA)


Recommended Posts

Posted

I've created a VBA routine that loops based on a selection set of blocks from my active drawing to create a new drawing, insert several blocks and save the drawing. The routine works fine the first time through the loop, but on the second pass I get a "Run-time Error: -2145386445 (80200033) Filer Error". It's getting caught up on the first insert block. When I remove the loop, I can run the routine over and over for the same selection from my active drawing without any problem, but if I make a different selection to run the routine for, I get the error. I can get it to work for the second selection by changing the block that I insert. When I switch back to the first selection, the same error occurs until I change the block again.

 

Set docObj = ThisDrawing.Application.Documents.Add("S:\Templates Active\acad electrical.dwt")

file = "c:\Cable Project\cable - " & k

ThisDrawing.SaveAs (file)

 

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

Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, border, 1, 1, 1, 0)

 

any ideas, and any help is appreciated. Thanks,

 

Nathan

Posted

I had problems similiar, and had to set variables for all my files, I couldn't just pass a path

Posted

doesn't seem to matter whether its a variable or a path, it never makes it past the first insert block.

Posted

I don’t do a lot of VBA. I like lisp or vlisp. I have had situations similar to this before. In lisp and correct me if I’m wrong, but the lisp or vba program is loaded into the active drawing not the overall AutoCAD environment. Therefore your program is loaded into the first drawing and executes the code to make a new drawing which becomes the active document which has no code loaded into it taking focus off the first drawing and causing the code to stop. In the past if I want to interact between two drawings I has to utilize a script. In the code I compiled all the info I needed and formatted it to write to a text file with a scr extension. Then have it write the file. Then the last thing in the code was a call to execute the script file.

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