×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VBA between Excel and AutoCAD

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.

RE: VBA between Excel and AutoCAD

Hi FastEddee,

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

(OP)
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?

RE: VBA between Excel and AutoCAD

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

RE: VBA between Excel and AutoCAD

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources