Your problem is that the Block's name (Block name cannot contain "\", ":",
or should not be a full file name), or more precisely, your logic, is wrong.
What you are intent to do is to insert a block from file.
The logic should be: if the block already exists in drawing(Blocks
collection), you supply the block name ("4x4") to InsertBlock() method; if
the block does not exists in drawing, you can supply a full file name
("C:\...\4x4.dwg") to InsertBlock() method, after inserting, block
definition "4x4" is created in Blocks collection automatically.
In your logic, you created a BLANK block definition without AcadEntity in
the block. So, even if your "Set mBlockObj..." was OK, the code after that
only insered a blank block, which contains nothing.
So, you should remove the code that creates an AcadBlock object. Directly go
to ThisDrawing.ModelSpace.InsertBlock(insPoint, "C:\...\4x4.dwg",....).
But to make your code bullet-proof, you may want to do some verification
before inserting:
1. decide to use block name or full file name in "InserBlock()" method. You
can first to loop through AcadBlocks collection to see if the Block ("4x4")
definition exists or not. If yes, you use block name, if not, you use full
file name;
2. if you use full file name, you want to check if the *.dwg ("4x4.dwg")
file exists or not.
BTW, since you post in .NET NG, which implies you use VB.NET, can you still
use Variant type in VB.NET? Can you still use "Set ..."? Although have been
doing VB/VBA for long time, but in .NET, I use C#, never used VB.NET. But I
know Variant type is gone in VB.NET.
wrote in message news:4972903@discussion.autodesk.com...
Below is the code for a sub that is being called from anouther one of my
subroutines. If you need the rest I can post it but lets hope that will not
be needed.
The error that I am getting is :
"calling method SetObjectId of Interface IAcadBaseObject failed"
Whats this mean and how do I look in the help sysstem for information as to
how to correct these errors?
MY code:
'This could be modified to run as a stand alone if you need to test it!
Sub InsertMyBlock(blockName As String, insertPnt As Variant)
' This example creates a block containing a circle. It then inserts the
block.
Dim filePath As String
filePath = "C:\Documents and Settings\Owner\Desktop\ACAD_STUFF\Blocks\"
' Create the block
Dim myBlockObj As AcadBlock
Dim myInsertionPnt(0 To 2) As Double
myInsertionPnt(0) = 0#
myInsertionPnt(1) = 0#
myInsertionPnt(2) = 0#
'myBlockObj = ThisDrawing.Blocks.Add(myInsertionPnt, filePath &
blockName)
Set myBlockObj = ThisDrawing.Blocks.Add(myInsertionPnt, "C:\Documents
and Settings\Owner\Desktop\ACAD_STUFF\Blocks\4x4.dwg")
' Insert the block
Dim blockRefObj As AcadBlockReference
myInsertionPnt(0) = insertPnt(0)
myInsertionPnt(1) = insertPnt(1)
myInsertionPnt(2) = 0
Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(myInsertionPnt,
"myBlockObj", 1#, 1#, 1#, 0)
ZoomAll
End Sub