Could we take a peek at the error it returns?

Registered forum members do not see this ad.
I am trying to insert two different blocks into another block. I have done this many times using the same code but now I am getting an error. I am really lost. The part of my code that is giving me trouble is below. At this point in the code MainBlock has already been set, InsertBlock1 and 2 have been defined and InStng and OutStng are the names of the two blocks that I want to insert. Does anyone have any suggestions?
Code:Dim BlockObj1 As AcadBlockReference Dim BlockObj2 As AcadBlockReference Set BlockObj1 = MainBlock.InsertBlock(InsertBlock1, InStng, 1, 1, 1, 0) Set BlockObj2 = MainBlock.InsertBlock(InsertBlock2, OutStng, 1, 1, 1, pi)
Could we take a peek at the error it returns?


ND
Where is the insertion point in your code?
Do you still have the examples from our last post?
It looks like you failed to define an insertion point for the blocks to be inserted.
Also, have you ever used The Locals (for debugging) in VBA?
ML


ND,
Also, what is Mainblock set to?
Your code needs to look something like this:
If you don't want the user to pick a point, then try hard coding the coords in:Code:Dim BlockObj1 As AcadBlockReference Dim Inspnt as Variant Inspnt = ThisDrawing.Utility.GetPoint(, "Please select the insertion point") Set BlockObj1 = ThisDrawing.ModelSpace.InsertBlock(Inspnt, "G:\PathToBlock\Blockname.dwg", 1, 1, 1, 0)
MLCode:Dim BlockObj1 As AcadBlockReference Set BlockObj1 = ThisDrawing.ModelSpace.InsertBlock(100,50,0, "G:\PathToBlock\Blockname.dwg", 1, 1, 1, 0)

Thanks all. It was a problem with the insertion point. All I had for my declaration was Dim insertblock1(0 to 2). I totally spaced the as double part. I feel smart![]()


Registered forum members do not see this ad.
Hey ND
Glad that helped
After I looked at your code, I thought that was it.
Yes, points are a little weird to understand at first.
Check it out,
If you are prompting a user to pick a point, then declare it as a variant type.
Dim pnt as Variant
If you are going to use the points coords X, Y and Z to do something like move the block, then you do this
Dim pnts (0 to 2) as Double
pnts (0) 'this = X
pnts (1) 'this = Y
pnts (2) 'this = Z
Data type double handles large numbers
If you'd like to see an example, I can post something
ML
Bookmarks