VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inserting "external" blocks in current drawing

1 REPLY 1
Reply
Message 1 of 2
Anonymous
217 Views, 1 Reply

Inserting "external" blocks in current drawing

Hello everyone:

I'm trying to create a VBA routine to insert blocks of doors & windows, but
need some help, please....

The door selection dialog has three combo boxes with Door Types, Wall Sizes
and Door Sizes.
See: http://www.bygroup.com/temp/insertdoors.jpg

Once the user selects all options and presses the insert button, I would
like to insert the block, but my problem is that all my doors are blocks
inside of a Template drawing.
See:http://www.bygroup.com/temp/masterdrawing.jpg

What I need to do is to insert a block FROM this external template into the
current drawing. I tried the "sendcommand" to use "-insert", but it seems
that that would only work if each door was an individual drawing.

Any suggestions?
Thank you in advance!

(please reply to newsgroup or "bstn-spam @ earthlink.net")

Bastian,
www.bygroup.com
Denver, CO
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

Here's an example function that will copy block definitions from one drawing
into another. The second procedure demonstrates how to copy the definitions
from an ObjectDBX document into the active drawing. Once the definitions
are in the drawing, you can insert them with the InsertBlock method.

'Copy block definitions from one drawing to another
Public Function CopyBlocks(sourceDB As AcadDatabase, targetDB As
AcadDatabase, ParamArray blockNames()) As Variant
Dim remoteBlocks() As AcadBlock
Dim localBlocks() As AcadBlock
Dim i As Long

'store the block(s) in an array
ReDim remoteBlocks(LBound(blockNames) To UBound(blockNames))
For i = LBound(blockNames) To UBound(blockNames)
Set remoteBlocks(i) = sourceDB.blocks(blockNames(i))
Next i

'Deepclone the block(s) into the current drawing
sourceDB.CopyObjects remoteBlocks(), targetDB.blocks

'Gather references to local block(s)
ReDim localBlocks(LBound(blockNames) To UBound(blockNames))
For i = LBound(blockNames) To UBound(blockNames)
Set localBlocks(i) = targetDB.blocks(blockNames(i))
Next i

'Return the local block(s)
CopyBlocks = localBlocks()
End Function

Public Sub TestCopyBlocks(fileName As String, ParamArray blockNames())
Dim dbxDoc As AxDbDocument
Dim copiedBlocks As Variant

On Error GoTo ErrorHandler:

'open remote file
Set dbxDoc = New AxDbDocument
dbxDoc.Open fileName

copiedBlocks = CopyBlocks(dbxDoc.Database, ThisDrawing.Database,
"3050wdw", "3060wdw")

ExitSub:
Set dbxDoc = Nothing
Exit Sub
ErrorHandler:
Debug.Print Err.Number & ": " & Err.Description
Resume ExitSub
End Sub
--
Bobby C. Jones
www.AcadX.com

"Marcos Bastian" wrote in message
news:2815C791B98765591C1FAE1A9058B19D@in.WebX.maYIadrTaRb...
> Hello everyone:
>
> I'm trying to create a VBA routine to insert blocks of doors & windows,
but
> need some help, please....
>
> The door selection dialog has three combo boxes with Door Types, Wall
Sizes
> and Door Sizes.
> See: http://www.bygroup.com/temp/insertdoors.jpg
>
> Once the user selects all options and presses the insert button, I would
> like to insert the block, but my problem is that all my doors are blocks
> inside of a Template drawing.
> See:http://www.bygroup.com/temp/masterdrawing.jpg
>
> What I need to do is to insert a block FROM this external template into
the
> current drawing. I tried the "sendcommand" to use "-insert", but it seems
> that that would only work if each door was an individual drawing.
>
> Any suggestions?
> Thank you in advance!
>
> (please reply to newsgroup or "bstn-spam @ earthlink.net")
>
> Bastian,
> www.bygroup.com
> Denver, CO
>
>

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost