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

Attach XREF with ObjectDBX... Can it be done?!?

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
184 Views, 2 Replies

Attach XREF with ObjectDBX... Can it be done?!?

Okay CAD Gurus... I'm looking to you for a little
help with this problem.  I've recently started to mess around with
ObjectDBX and I've run into a wall.  I'm trying to attach an external
reference into a drawing and then save it, but.... It seems to only attach
the file to the drawing that I currently have open and not the one that I
specify in the code.

Here's my code.

 

 

Public Sub testDXB()
    Dim
DbxDoc As AxDbDocument
    Dim varPnt As
Variant
    Dim dblX As Double
    Dim
dblAngle As Double
    Dim objUtil As Object

    dblAngle = CDbl(0 / 180 *
(Atn(1) * 4))
    Set objUtil =
ThisDrawing.Utility
    objUtil.CreateTypedArray varPnt,
vbDouble, 0#, 0#, 0#
    dblX = CDbl(1#)
   
Set DbxDoc =
ThisDrawing.Application.GetInterfaceObject("ObjectDBX.AxDbDocument.16")

face=Tahoma size=2>

    DbxDoc.Open
"e:\work\drawing1.dwg"
   
DbxDoc.ModelSpace.AttachExternalReference "e:\work\drawing2.dwg", "DRAWING2",
varPnt, dblX, dblX, dblX, dblAngle, True
    DbxDoc.SaveAs
"e:\work\DRAWING3.dwg"

    Set DbxDoc = Nothing
End Sub

 


--
Matt W
 
There are 3 kinds of people:
  Those
who can count, and those who can't.
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

You need to read the documentation for ODX. There is no model space,
thisdrawing, etc. That's why it is inserting into the current
drawing...the scary part is that your code should be popping an error ~
unless you have option explicit turned off.

In the ODX documentation, search for OdCreateXrefBlock. This is the
method for inserting an xref.

___________________________
Mike Tuersley
AutoCAD Clinic
Rand IMAGINiT Technologies
Message 3 of 3
Anonymous
in reply to: Anonymous

You can't attach external references to drawings unless
they're open in the AutoCAD editor.

--
AcadXTabs: Document Tabs for AutoCAD
http://www.acadxtabs.com


"Matt W" wrote in message news:A9CDDE8E14C1F71E7AA1C5E461C16EDB@in.WebX.maYIadrTaRb...
> Okay CAD Gurus... I'm looking to you for a little help with this problem. I've recently started to mess around with
ObjectDBX and I've run into a wall. I'm trying to attach an external reference into a drawing and then save it, but....
It seems to only attach the file to the drawing that I currently have open and not the one that I specify in the code.
> Here's my code.
>
>
> Public Sub testDXB()
> Dim DbxDoc As AxDbDocument
> Dim varPnt As Variant
> Dim dblX As Double
> Dim dblAngle As Double
> Dim objUtil As Object
>
> dblAngle = CDbl(0 / 180 * (Atn(1) * 4))
> Set objUtil = ThisDrawing.Utility
> objUtil.CreateTypedArray varPnt, vbDouble, 0#, 0#, 0#
> dblX = CDbl(1#)
> Set DbxDoc = ThisDrawing.Application.GetInterfaceObject("ObjectDBX.AxDbDocument.16")
>
> DbxDoc.Open "e:\work\drawing1.dwg"
> DbxDoc.ModelSpace.AttachExternalReference "e:\work\drawing2.dwg", "DRAWING2", varPnt, dblX, dblX, dblX, dblAngle,
True
> DbxDoc.SaveAs "e:\work\DRAWING3.dwg"
>
> Set DbxDoc = Nothing
> End Sub
>
>
> --
> Matt W
>
> There are 3 kinds of people:
> Those who can count, and those who can't.
>

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

Post to forums  

Autodesk Design & Make Report

”Boost