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

Attach xref

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
stefano.cartaKGT96
284 Views, 3 Replies

Attach xref

Hi guys..

I use this code for open in memory a dwg and attach an xref to it and save the dwg.

when I open the dwg with Autocad I can view the attached xref in the xref palette, but I can't view it in the drawing.

 

what am I doing wrong?

Dim xrefDb As Database = New Database(False, True)
                xrefDb.ReadDwgFile(Item.ToString, FileShare.ReadWrite, False, "")

                Using trx As Transaction = xrefDb.TransactionManager.StartTransaction()

                    Dim xrefBt As BlockTable = xrefDb.BlockTableId.GetObject(OpenMode.ForRead)
                    Dim btrMs As BlockTableRecord = xrefBt(BlockTableRecord.PaperSpace).GetObject(OpenMode.ForWrite)

                    Dim xrefObjId As ObjectId = xrefDb.AttachXref(NomeFileCart, Path.GetFileNameWithoutExtension(NomeFileCart))

                    Dim bref As New BlockReference(Point3d.Origin, xrefObjId)

                    btrMs.AppendEntity(bref)
                    trx.AddNewlyCreatedDBObject(bref, True)

                    xrefDb.CloseInput(True)
                    xrefDb.SaveAs(Item.ToString, DwgVersion.Current)

                    trx.Commit()

                End Using
                xrefDb.SaveAs(Item.ToString, DwgVersion.AC1032)
3 REPLIES 3
Message 2 of 4
_gile
in reply to: stefano.cartaKGT96

Hi,

Why do save the database twice?



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 4
stefano.cartaKGT96
in reply to: _gile

HI....

I didn't notice the double SAVE thanks..

 

 

Message 4 of 4

I found the problem .... the xref file only had objects in the paperspace ...

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report