Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Use VBA to insert dwg file as block? 1

Status
Not open for further replies.

blim

Mechanical
Nov 5, 2001
7
I have used VBA to insert a previously defined block in a drawing, and even create block definitions.
Can VBA also be used to insert another dwg file as a block? What is the code? I have tried simply adding the file path info to the insert block code, but with no success.

Thanks to all who respond :)
 
Replies continue below

Recommended for you

The operative part of your code for this purpose would be as under.

Code:
Sub InsDwg()
  Dim BlockRef As AcadBlockReference
  Dim insertionPnt(0 To 2) As Double
  insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0#
  FileToInsert = "C:\Documents and Settings\Mala Singh\Desktop\Test.dwg"
  Set BlockRef = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, FileToInsert, 1#, 1#, 1#, 0)
End Sub

The 1,1,1,0 you see in the arguments list are x- y- z- scaling factors and rotation angle respectively



Mala Singh
'Dare to Imagine'
 
Mala
I hope you dont mind me asking. I have a very interesting
project that I just got pushed into and could use a little
help.

I need to launch Autocad R14 from the Web, have it
load a drawing insert a block of text into the drawing
then close with out anyone knowing that it happened.

All the code that I have written for Autocad depends on
user interaction...
Is there a way I could force code to run as soon as Autocad
opens?

Thank you
William O'Malley
 

WillOMalley:

I would definitely help if I could...

Unfortunately, I do not have any experience of launching apps from the web. Also, I do not know of the extent to which AutoCad R14 supports VBA (if at all). I am familiar with versions 2000 and 2004.

However, I'll try to find a way to auto-run a piece of code on launching of ACad on a desktop - if I succeed, you might try to adapt that to your work.



Mala Singh
'Dare to Imagine'
 
Mala,

Thanks for the reply, you're a life saver.

- Brent Lim
 
Glad to be of help...
FYI: The forum also provides you with another means of expressing appreciation (less transparent but no less meaningful)...you might like to find this out.


Mala Singh
'Dare to Imagine'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor