.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AttachXref to DWG not opened in AutoCAD

9 REPLIES 9
Reply
Message 1 of 10
j_degner
927 Views, 9 Replies

AttachXref to DWG not opened in AutoCAD

I have a project that is requiring a dwg to be copied, along with the external references. On this new dwg file in the separate drive, I need to change the external references, to the newly created external reference files on the separate drive.

I save the currently opened dwg file and all external references to a separate drive. That part is done.

Next, my approach was to get the new dwg file on the separate drive, delete all external references, then reattach the new external references on the separate drive.

I have been able to get the dwg file, delete the external references. But now I'm stuck.

I can't seem to figure out a way of attaching an external reference to a dwg file that isn't opened in AutoCAD. Is it possible? Do I need RealDWG for this?

I'm currently using AutoCAD 2010 and ObjectARX 2010 .Net

Any help is greatly appreciated

Thanks
Jerri
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: j_degner

As long as the xrefs are located on the same drive as the master and you
recreate the same folder structure on your copy location you shouldn't need
to do anything if using "relative path" when attaching the xrefs to the master.

If not using "relative path" you have some work ahead.

Sorry I can't be much help here but I know you'll need to detect the insertion
point, scale, overlay or attachment, and orientation of each xref in the
master then recreate it on the copied master when you reattach the xref.





> I have a project that is requiring a dwg to be copied, along with the
> external references. On this new dwg file in the separate drive, I
> need to change the external references, to the newly created external
> reference files on the separate drive.
>
> I save the currently opened dwg file and all external references to a
> separate drive. That part is done.
>
> Next, my approach was to get the new dwg file on the separate drive,
> delete all external references, then reattach the new external
> references on the separate drive.
>
> I have been able to get the dwg file, delete the external references.
> But now I'm stuck.
>
> I can't seem to figure out a way of attaching an external reference to
> a dwg file that isn't opened in AutoCAD. Is it possible? Do I need
> RealDWG for this?
>
> I'm currently using AutoCAD 2010 and ObjectARX 2010 .Net
>
> Any help is greatly appreciated
>
> Thanks
> Jerri
Message 3 of 10
NathTay
in reply to: j_degner

Can you just change the path of the existing XREF?
Message 4 of 10
Anonymous
in reply to: j_degner

Have you tried just setting the PathName property of the
XRef's BlockTableRecord to the new path, or are you
taking the scenic route for another reason?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6327128@discussion.autodesk.com...
I have a project that is requiring a dwg to be copied, along with the external
references. On this new dwg file in the separate drive, I need to change the
external references, to the newly created external reference files on the
separate drive.

I save the currently opened dwg file and all external references to a separate
drive. That part is done.

Next, my approach was to get the new dwg file on the separate drive, delete all
external references, then reattach the new external references on the separate
drive.

I have been able to get the dwg file, delete the external references. But now
I'm stuck.

I can't seem to figure out a way of attaching an external reference to a dwg
file that isn't opened in AutoCAD. Is it possible? Do I need RealDWG for this?

I'm currently using AutoCAD 2010 and ObjectARX 2010 .Net

Any help is greatly appreciated

Thanks
Jerri
Message 5 of 10
j_degner
in reply to: j_degner

That did it! Sorry for the stupid question everyone. Thanks for all of your help getting me on the right route 🙂

Thanks
Jerri
Message 6 of 10
j_degner
in reply to: j_degner

I'm now changing the path for an xref. However, the new filename/path for the xref does not have file extension, it is stripped by the other product I'm integrating with. When I open the drawing, it's says that the xrefs weren't found, and I think this is because they don't have the "dwg" extension. Am I correct? If so, Is there a way around this? Edited by: j_degner on Feb 2, 2010 9:36 AM
Message 7 of 10
j_degner
in reply to: j_degner

I'm now changing the path for an xref. However, the new filename/path for the xref does not have file extension, it is stripped by the other product I'm integrating with. When I open the drawing, it's says that the xrefs weren't found, and I think this is because they don't have the "dwg" extension. Am I correct? If so, Is there a way around this?
Message 8 of 10
Ontario70
in reply to: j_degner

> {quote:title=j_degner wrote:}{quote}
> I have been able to get the dwg file, delete the external references. But now I'm stuck.

How did you do that? I'm stuck at that place...

Thx
Ontario
Message 9 of 10
j_degner
in reply to: j_degner

I hope this helps.....


Dim newXDb As Database = New Database(False, True)
newXDb.ReadDwgFile(strfilepath, System.IO.FileShare.ReadWrite, False, "")
Dim xrefTr As Transaction = newXDb.TransactionManager.StartTransaction()
Using xrefTr
Dim bTable As BlockTable = xrefTr.GetObject(newXDb.BlockTableId, OpenMode.ForWrite)
Dim bRecord As BlockTableRecord = xrefTr.GetObject(bTable(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
Dim iter As IEnumerator = bRecord.GetEnumerator
Dim i As Integer = 0
While iter.MoveNext
Dim id As ObjectId = iter.Current
Dim ent As Entity = CType(xrefTr.GetObject(id, OpenMode.ForWrite), Entity)
If (TypeOf ent Is BlockReference) Then
Dim bref As BlockReference = CType(xrefTr.GetObject(ent.ObjectId, OpenMode.ForWrite), BlockReference)
Dim blkRec As BlockTableRecord = CType(xrefTr.GetObject(bref.BlockTableRecord, OpenMode.ForRead), BlockTableRecord)

If blkRec.IsFromExternalReference Then
If bref.IsWriteEnabled = True Then
bref.Erase()
bref.Dispose()
i += 1
End If
ent.Dispose()


End If
End If
End While

MsgBox("Blocks deleted: " & i)
xrefTr.Commit()
newXDb.SaveAs(strfilepath, DwgVersion.Current)
xrefTr.Dispose()
newXDb.Dispose()
End Using
Message 10 of 10
Ontario70
in reply to: j_degner

Very great! Danke schoen!

Ontario

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost