Community
db.DetachXref(blkDef.ObjectId);
gl-Paul
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi Guys, Searching 'xref' using
the 'Object Browser' I found
'DetachXref'.
Did a test and this seems to work
db.DetachXref(blkDef.ObjectId);
gl-Paul
"Art Cooney" <Yes calling acedXrefUnload()
href="mailto:artc@autodesk.com">
size=2>artc@autodesk.com> wrote in
message
size=2>news:5210064@discussion.autodesk.com
size=2>...
would do it.
When I responded, I was thinking within the context of the
existing AutoCAD
.NET APIs only, not making your own wrapper for an
unmanaged C++ function.
Nicely done. 🙂
<Alexander
Rivilis> wrote in message
href="news:5210042@discussion.autodesk.com">
size=2>news:5210042@discussion.autodesk.com
size=2>...
What about this code?
[code]
using System;
using
System.Runtime.InteropServices;
using Autodesk.AutoCAD.Runtime;
using
Autodesk.AutoCAD.Geometry;
using
Autodesk.AutoCAD.ApplicationServices;
using
Autodesk.AutoCAD.DatabaseServices;
using
Autodesk.AutoCAD.EditorInput;
[assembly:
CommandClass(typeof(XrefLib.XrefClass))]
namespace
XrefLib
{
public class XrefClass
{
// For AutoCAD 2006:
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Ansi,
EntryPoint="
href="mailto:?acedXrefUnload@@YA?AW4ErrorStatus@Acad@@PBD_NPAVAcDbDatabase@@@Z">
face=Arial
...
face=Arial size=2>")
]
// For
AutoCAD 2007:
//
[DllImport("acad.exe", CallingConvention =
CallingConvention.Cdecl,
CharSet = CharSet.Unicode,
//
EntryPoint="
href="mailto:?acedXrefUnload@@YA?AW4ErrorStatus@Acad@@PB_W_NPAVAcDbDatabase@@@Z">
face=Arial
...
face=Arial size=2>")
]
extern static int
acedXrefUnload(string XrefBlockname, bool bQuiet,
IntPtr
db);
// For AutoCAD 2006:
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acdb16.dll", CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Ansi)]
// For AutoCAD
2007:
//
[System.Security.SuppressUnmanagedCodeSecurity]
// [DllImport("acdb17.dll", CallingConvention =
CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
extern static string acadErrorStatusText(int
unnamed);
static private int XrefUnload(string
XrefBlockname, bool bQuite,
Database db)
{
return
acedXrefUnload(XrefBlockname,bQuite,(db ==
null)?IntPtr.Zero:db.UnmanagedObject);
}
[CommandMethod("XUNLOAD")]
static public void XUnload()
{
Editor ed =
Application.DocumentManager.MdiActiveDocument.Editor;
PromptStringOptions pr = new PromptStringOptions("\nType
XrefBlockName:
"); pr.AllowSpaces = true;
PromptResult res
= ed.GetString(pr);
if (res.Status ==
PromptStatus.OK)
{
if
(XrefUnload(res.StringResult,true,HostApplicationServices.WorkingDatabase)
!=0)
{
ed.WriteMessage("\nError in unloading xref <{0}>",
res.StringResult);
}
}
}
}
}
[/code]
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Art Cooney" <
href="mailto:artc@autodesk.com">artc@autodesk.com> wrote in message
href="news:5210122@discussion.autodesk.com">news:5210122@discussion.autodesk.com...
Detach and unload are two different things.
Detach completely removes the xref from the drawing as though it had never
been attached. Whereas, unload simply unloads the xref - sort of like if
the xref was not found when the drawing was opened.
I just checked the source and DetachXref() does
indeed do a detach, not an unload. DetachXref() is a wrapper for the
ObjectARX function acdbDetachXref().
DetachXref() (and acdbDetachXref()) should not be
called on any xref that has any unerased BlockReferences referencing
it.
"Paul Richardson" <prichardsonATadelphia.net> wrote in message
href="news:5210102@discussion.autodesk.com">news:5210102@discussion.autodesk.com...
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi Guys, Searching 'xref' using
the 'Object Browser' I found
'DetachXref'.
Did a test and this seems to work
db.DetachXref(blkDef.ObjectId);
gl-Paul
"Art Cooney" <Yes calling
href="mailto:artc@autodesk.com">
size=2>artc@autodesk.com> wrote in
message
face=Arial size=2>news:5210064@discussion.autodesk.com
face=Arial size=2>...
acedXrefUnload() would do it.
When I responded, I was thinking within
the context of the existing AutoCAD
.NET APIs only, not making your own
wrapper for an unmanaged C++ function.
Nicely done.
🙂
<Alexander Rivilis> wrote in message
href="news:5210042@discussion.autodesk.com">
size=2>news:5210042@discussion.autodesk.com
size=2>...
What about this code?
[code]
using System;
using
System.Runtime.InteropServices;
using Autodesk.AutoCAD.Runtime;
using
Autodesk.AutoCAD.Geometry;
using
Autodesk.AutoCAD.ApplicationServices;
using
Autodesk.AutoCAD.DatabaseServices;
using
Autodesk.AutoCAD.EditorInput;
[assembly:
CommandClass(typeof(XrefLib.XrefClass))]
namespace
XrefLib
{
public class XrefClass
{
// For AutoCAD 2006:
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Ansi,
EntryPoint="
href="mailto:?acedXrefUnload@@YA?AW4ErrorStatus@Acad@@PBD_NPAVAcDbDatabase@@@Z">
face=Arial...
face=Arial size=2>")
]
// For
AutoCAD 2007:
//
[DllImport("acad.exe", CallingConvention =
CallingConvention.Cdecl,
CharSet = CharSet.Unicode,
//
EntryPoint="
href="mailto:?acedXrefUnload@@YA?AW4ErrorStatus@Acad@@PB_W_NPAVAcDbDatabase@@@Z">
face=Aria...
face=Arial size=2>")
]
extern static int
acedXrefUnload(string XrefBlockname, bool bQuiet,
IntPtr
db);
// For AutoCAD 2006:
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acdb16.dll", CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Ansi)]
// For
AutoCAD 2007:
//
[System.Security.SuppressUnmanagedCodeSecurity]
// [DllImport("acdb17.dll", CallingConvention =
CallingConvention.Cdecl, CharSet =
CharSet.Unicode)]
extern static string
acadErrorStatusText(int unnamed);
static private
int XrefUnload(string XrefBlockname, bool bQuite,
Database
db)
{
return
acedXrefUnload(XrefBlockname,bQuite,(db ==
null)?IntPtr.Zero:db.UnmanagedObject);
}
[CommandMethod("XUNLOAD")]
static public void XUnload()
{
Editor ed =
Application.DocumentManager.MdiActiveDocument.Editor;
PromptStringOptions pr = new PromptStringOptions("\nType
XrefBlockName:
"); pr.AllowSpaces = true;
PromptResult
res = ed.GetString(pr);
if (res.Status ==
PromptStatus.OK)
{
if
(XrefUnload(res.StringResult,true,HostApplicationServices.WorkingDatabase)
!=0)
{
ed.WriteMessage("\nError in unloading xref <{0}>",
res.StringResult);
}
}
}
}
}
[/code]
Can't find what you're looking for? Ask the community or share your knowledge.