Use VBA to insert dwg file as block?
Use VBA to insert dwg file as block?
(OP)
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 :)
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 :)





RE: Use VBA to insert dwg file as block?
CODE
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'
RE: Use VBA to insert dwg file as block?
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
RE: Use VBA to insert dwg file as block?
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'
RE: Use VBA to insert dwg file as block?
Thanks for the reply, you're a life saver.
- Brent Lim
RE: Use VBA to insert dwg file as block?
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'