Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA between Excel and AutoCAD 1

Status
Not open for further replies.

FastEddee

Civil/Environmental
Joined
Oct 11, 2005
Messages
6
Location
US
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.
 
Hi FastEddee,

Once you've created your 3DFace, you'll need to use the Blocks.Add method, not the wblock command.

HTH
Todd
 
That's what I thought, but when I read the example code in the ACAD help menu I got confused. Here's why. The Example code reads as follows.

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?
 
Hi FastEddie,

Ah, that's different. You need to use the CopyObjects method, so you would have a line something linke this:

Code:
ThisDrawing.CopyObjects entArray, blockObj

The CopyObjects method requires an array, so you'll need to place your objects to add in an array.

HTH
Todd
 
Thanks,
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top