.NET

Reply
Contributor
vasantpadhiyar71
Posts: 23
Registered: ‎05-25-2012
Message 1 of 7 (655 Views)
Accepted Solution

How can I get Direct xref of a Particular Drawing using C# Code?

655 Views, 6 Replies
05-25-2012 06:10 AM

Hi All,

 

Suppose I have a Drawing Structure like:
MasterRoot
    Root1
        MasterChild1
            Child
        MasterChild2
            Child
    Root2
        MasterChild1
            Child
        MasterChild2
            Child

When I use XrefGraph xg = mainDb.GetHostDwgXrefGraph(true); in Code then I get all the Files as a node including MasterRoot (say count=6).
If I want to get Only direct Children (here, Root1 and Root2)(means count=2 only), then wha i have to do?
Is it Possible?
Any help will be appreciated.

Thanks in Advance..

Thanks & Regards,
Vasant Padhiyar

Vasant PADHIYAR

Thanks Art,

 

I have done it using the same Concept and it works fine.

 

1. Get the root node (which is effectively the host drawing), i.e.:

 

    XrefGraph graph = db.GetHostDwgXrefGraph(true);
    XrefGraphNode rootNode = graph.RootNode;

 

2. Then use the XrefGraphNode.NumIn property and XrefGraphNode.In(int i) method to iterate child nodes recursively.

 

Thanks,

 

Distinguished Contributor
Artvegas
Posts: 104
Registered: ‎04-21-2011
Message 2 of 7 (646 Views)

Re: How can I get Direct xref of a Particular Drawing using C# Code?

05-25-2012 06:47 AM in reply to: vasantpadhiyar71

Have you tried the XrefGraphNode.IsNested property?

 

From the ObjectARX docs for this property:

"Returns True if this node represents a nested xref that is not directly referenced in the host drawing."

 

So in code you could check for this property to be false, i.e.:

 

XrefGraph graph = db.GetHostDwgXrefGraph(true);
for (int i = 0; i < graph.NumNodes; i++)
{
	XrefGraphNode node = graph.GetXrefNode(i);
	if (!node.IsNested)
	{
		// < Insert your code for non-nested xref here >
	}
}

 

Haven't tried this myself but hopefully this will help you out.

 

Art

Contributor
vasantpadhiyar71
Posts: 23
Registered: ‎05-25-2012
Message 3 of 7 (620 Views)

Re: How can I get Direct xref of a Particular Drawing using C# Code?

05-25-2012 11:38 PM in reply to: Artvegas

Thanks a lot...

It is really helpful for me...

Vasant PADHIYAR
Contributor
vasantpadhiyar71
Posts: 23
Registered: ‎05-25-2012
Message 4 of 7 (607 Views)

Re: How can I get Direct xref of a Particular Drawing using C# Code?

05-27-2012 10:02 PM in reply to: vasantpadhiyar71

Hi All,

 

Now Actually I wants the xRef Structure in a Tree Structure as it is in AutoCAD Drawing.

 

How to traverse recursively to generate a Tree Structure same as xRef Structure.

 

Thanks & Regards,

Vasant Padhiyar

Vasant PADHIYAR
Distinguished Contributor
Artvegas
Posts: 104
Registered: ‎04-21-2011
Message 5 of 7 (579 Views)

Re: How can I get Direct xref of a Particular Drawing using C# Code?

05-30-2012 11:44 AM in reply to: vasantpadhiyar71

Hi,

 

The ObjectARX docs say something like this...

 

Each reference (between databases) is represented by an edge in the graph, and can be queried by calling GraphNode.In(int index) for what is referencing this node...

 

I haven't tried to do this, but looking at the ObjectARX documentation I would try the following:

 

1. Get the root node (which is effectively the host drawing), i.e.:

 

    XrefGraph graph = db.GetHostDwgXrefGraph(true);
    XrefGraphNode rootNode = graph.RootNode;

 

2. Then use the XrefGraphNode.NumIn property and XrefGraphNode.In(int i) method to iterate child nodes recursively.
    

You might need to experiment and step through in debug mode to see what's happening under the hood. I've never looked closely at it.

 

Good luck, Art

Contributor
vasantpadhiyar71
Posts: 23
Registered: ‎05-25-2012
Message 6 of 7 (569 Views)

Re: How can I get Direct xref of a Particular Drawing using C# Code?

05-30-2012 10:59 PM in reply to: Artvegas

Thanks Art,

 

I have done it using the same Concept and it works fine.

 

1. Get the root node (which is effectively the host drawing), i.e.:

 

    XrefGraph graph = db.GetHostDwgXrefGraph(true);
    XrefGraphNode rootNode = graph.RootNode;

 

2. Then use the XrefGraphNode.NumIn property and XrefGraphNode.In(int i) method to iterate child nodes recursively.

 

Thanks,

 

Vasant PADHIYAR
Distinguished Contributor
Artvegas
Posts: 104
Registered: ‎04-21-2011
Message 7 of 7 (546 Views)

Re: How can I get Direct xref of a Particular Drawing using C# Code?

06-05-2012 05:15 AM in reply to: vasantpadhiyar71
A few days later... Finding all XREFs in the current database using C#.NET: http://adndevblog.typepad.com/autocad/2012/06/finding-all-xrefs-in-the-current-database-using-cnet.h...
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.