VBA between Excel and AutoCAD
VBA between Excel and AutoCAD
(OP)
I am in need of assistance. I have written a VBA routine that takes input from an Excel spreadsheet and creates a basic AutoACD drawing from it. I need to draw a 3DFace as part of the drawing and then make this 3DFace a block. I have tried using the wBlock command, but I can't seem to get it to work.
Does anyone have any general ideas? I can place the non-working code that I have written into a reply if it would help. I don't have it here with me right now.
Thanks.
Does anyone have any general ideas? I can place the non-working code that I have written into a reply if it would help. I don't have it here with me right now.
Thanks.





RE: VBA between Excel and AutoCAD
Once you've created your 3DFace, you'll need to use the Blocks.Add method, not the wblock command.
HTH
Todd
RE: VBA between Excel and AutoCAD
Dim blockObj as AcadBlock
'Define the block
Dim insertionPnt(0 to 2) as Double
insertionPnt(0) = 0#; insertionPnt(1) = 0#; insertionPnt(2) = 0#
'Add the block to the blocks collection
Set block.Obj = ThisDrawing.Blocks.Add(insertionPnt, "New Block")
I understand that the last line is creating a block called "New Block" and adding it to the blocks collection, but how does the code know what objects are supposed to be included in the block?
Currently, I have a line in my code that reads as follows.
Set Plywood = ModelSpace.Add3DFace(InsertPt, Corner2, Corner3, Corner4)
It seems to me that the next line should be the Blocks.Add method. But how do I tell the code that I want the block to have my 3DFace called Plywood in it?
RE: VBA between Excel and AutoCAD
Ah, that's different. You need to use the CopyObjects method, so you would have a line something linke this:
CODE
The CopyObjects method requires an array, so you'll need to place your objects to add in an array.
HTH
Todd
RE: VBA between Excel and AutoCAD
I think I may have found another way around my problem. I found a posing on the AutoDesk web site about anonymous blocks that I have borrowed some code from. It appears to be working, but I'll keep your reply in mind in case I find out it isn't doing what I think it is.