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

Does any one know how to bind xref's

8 REPLIES 8
Reply
Message 1 of 9
michael_vanhoose
634 Views, 8 Replies

Does any one know how to bind xref's

Does any one know how to Bind Xrefs in the drawings using .net? There must be a easy way other than inserting it in a as a block then saving the state of all those layers.
8 REPLIES 8
Message 2 of 9
cadMeUp
in reply to: michael_vanhoose

I have not tried it but this should work:
Database.BindXrefs(Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection, bool)

Call this on a database that contains the Xref that you want to bind in.

You can find it in the object browser.
Message 3 of 9
Anonymous
in reply to: michael_vanhoose

//Database.BindXrefs(Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection,
bool)

What AutoCAD version?



As far for A2007.... you can P/Invoke acedXrefBind();

There are some samples already done and posted here.... do a search in this
newsgroup.
Message 4 of 9

I have 2007 and I can't see db.bindxref in my object browser. I did a search many times on xrefs,bind and nothing comes up. if you have a link of something that would be very nice.

Also, thanks for your reply.
Message 5 of 9
Anonymous
in reply to: michael_vanhoose

/*
I have 2007 and I can't see db.bindxref in my object browser. I did a
search many times on xrefs,bind and
nothing comes up. if you have a link of something that would be very nice.

Also, thanks for your reply.
*/

Strange....

but here is something:

[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet
= CharSet.Unicode,
EntryPoint =
"acedXrefBind@@YAAW4ErrorStatus@Acad@@PB_W_N1PAVAcDbDatabase@@@Z")]

extern public static ErrorStatus acedXrefBind(string XrefBlockname, bool
bInsertBind, bool bQuiet, IntPtr db);


using (Transaction tr =
db.TransactionManager.StartTransaction())
{
BlockReference blkRef = tr.GetObject(id,
OpenMode.ForWrite, false) as BlockReference;
BlockTableRecord blkRec =
(BlockTableRecord)tr.GetObject(blkRef.BlockTableRecord, OpenMode.ForWrite);
if (blkRec.IsFromExternalReference)
{
string blockname = blkRec.Name, fileName =
blkRec.PathName; Point3d origin = blkRec.Origin;
if (acedXrefBind(blockname, true, true,
HostApplicationServices.WorkingDatabase.UnmanagedObject) == ErrorStatus.OK)
ed.WriteMessage("\nXref was binded...");
Message 6 of 9
cadMeUp
in reply to: michael_vanhoose

Sorry, I did not realize it was for 2007 and you are right I do not see it there for that version.

You could try this:
string xrefname = "SOME_XREF_NAME";
string comStr = String.Format("-xref bind {0}\n", xrefname);
AcadApp.DocumentManager.MdiActiveDocument.SendStringToExecute(comStr, false, false, false);

It will produce what you want, but it is an odd way.
Message 7 of 9

did they add this in 2008 Database.BindXrefs(Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection,
bool)? I guess I'm better off using COM. I'm trying to get away from COM.
Message 8 of 9
cadMeUp
in reply to: michael_vanhoose

Yes, it is in 2008. Strange that they don't have a direct way in 2007. You could insert the xref database into the dwg that contains it, as a block, and just give it a new block name, but that would not remove the xref from the database which is what I assume you want? Can I ask what the reason is for binding the xref to the dwg?
Message 9 of 9

When we send them to customers we bind them. That's good to know about 2008 though. They must have thought about.

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