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

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

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
vasantpadhiyar71
2185 Views, 6 Replies

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

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
6 REPLIES 6
Message 2 of 7
Artvegas
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

Message 3 of 7
vasantpadhiyar71
in reply to: Artvegas

Thanks a lot...

It is really helpful for me...

Vasant PADHIYAR
Message 4 of 7

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
Tags (1)
Message 5 of 7
Artvegas
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

Message 6 of 7
vasantpadhiyar71
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
Message 7 of 7
Artvegas
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...

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