Blocks.Add method

#1
I am trying to create a Block in Cadopia 6 Pro.

Here is the stripped down code I am using:

Dim CurrentDwg As Document
Dim TempBlock As IntelliCAD.Block
Dim InsertPoint As IntelliCAD.Point

Set CurrentDwg = Application.ActiveDocument
Set InsertPoint = Library.CreatePoint(0, 0, 0)
Set TempBlock = CurrentDwg.Blocks.Add(InsertPoint, "FOOBAR")

The last line produces the following error message:

Run-time error '-2147467259(80004005)':
Method 'Add' of Object "IIcadBlocks' failed

(Whew! That's a great error number!)

I have also tried this:

Set TempBlock = IntelliCAD.Blocks.Add(InsertPoint, "FOOBAR")

Same error.

This sure looks like the same sort of code in the Developer's
Reference.

Can someone show me the error of my ways?

Thanks in advance.

#2
Steve,

It appears that you need an insert object

Dim blockObj As IntelliCAD.Block
Dim insPt As IntelliCAD.Point
' Insert the block

Dim blockRefObj As IntelliCAD.BlockInsert

Set blockRefObj = ThisDocument.ModelSpace.InsertBlock(insPt, BlkName, 1, 1, 0)

ssc

#3
ssc -

Thanks for the response. I am trying to create a Block, not just Insert it.

In other words, I am trying to create a Block object using VBA code, not just place an existing Block somewhere in the .DWG.

I know I can use a template .DWG to get around this (which I am currently doing), but the basic code I am working with runs OK in ACAD and I would like to port all of the program (if possible) directly to ICAD.

Mostly curious about what I am doing wrong.
cron