Message 1 of 1
Could not Promote Wires in c sharp

Not applicable
01-27-2010
11:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am trying to promote wires from the construction geometry to the sketch.
It works very well in VBA macro.
somehow it fails when it comes to c sharp.
I have attached the a part document containing wires and below c sharp code is used to promote wires.
The function PromoteWires() is written to promote the wires.
In this function, a part document is made as active document.
Required node(construction geometry) which contains wires is selected.
and promote wire command is fired using command manager.
Result is, it simply adds a sketch but the sketch doesn't contain required sketch entities.
Please Suggest if i am missing anything in doing it.
Looking forward for your reply.
Thank you.
C Sharp Snippet:
private void PromoteWires()
{
PartDocument oPartSATDoc = (Inventor.PartDocument)m_inventorApp.ActiveDocument;
BrowserNode oTopBrowserNode;
oTopBrowserNode = oPartSATDoc.BrowserPanes.ActivePane.TopNode;
BrowserNode oRequiredNode;
oRequiredNode = recurseNodes(oTopBrowserNode, "Wires");
oRequiredNode.DoSelect();
CommandManager oCommandMgr;
oCommandMgr = m_inventorApp.CommandManager;
ControlDefinition oControlDef;
oControlDef = oCommandMgr.ControlDefinitions["PartConstructionPromoteWireCtxCmd"];
oControlDef.Execute();
}
private Inventor.BrowserNode recurseNodes(Inventor.BrowserNode oTopNode, String strWantedNode)
{
BrowserNode tempnode = null;
if (oTopNode.FullPath.Contains(strWantedNode))
{
tempnode = oTopNode;
}
else
{
BrowserNode oBN = null;
if (oTopNode.BrowserNodes.Count != 0)
{
foreach (BrowserNode oBN1 in oTopNode.BrowserNodes)
{
oBN = oBN1;
tempnode = recurseNodes(oBN, strWantedNode);
if (!(tempnode == null))
{
break;
}
}
}
else
{
tempnode = null;
}
}
return tempnode;
}
I am trying to promote wires from the construction geometry to the sketch.
It works very well in VBA macro.
somehow it fails when it comes to c sharp.
I have attached the a part document containing wires and below c sharp code is used to promote wires.
The function PromoteWires() is written to promote the wires.
In this function, a part document is made as active document.
Required node(construction geometry) which contains wires is selected.
and promote wire command is fired using command manager.
Result is, it simply adds a sketch but the sketch doesn't contain required sketch entities.
Please Suggest if i am missing anything in doing it.
Looking forward for your reply.
Thank you.
C Sharp Snippet:
private void PromoteWires()
{
PartDocument oPartSATDoc = (Inventor.PartDocument)m_inventorApp.ActiveDocument;
BrowserNode oTopBrowserNode;
oTopBrowserNode = oPartSATDoc.BrowserPanes.ActivePane.TopNode;
BrowserNode oRequiredNode;
oRequiredNode = recurseNodes(oTopBrowserNode, "Wires");
oRequiredNode.DoSelect();
CommandManager oCommandMgr;
oCommandMgr = m_inventorApp.CommandManager;
ControlDefinition oControlDef;
oControlDef = oCommandMgr.ControlDefinitions["PartConstructionPromoteWireCtxCmd"];
oControlDef.Execute();
}
private Inventor.BrowserNode recurseNodes(Inventor.BrowserNode oTopNode, String strWantedNode)
{
BrowserNode tempnode = null;
if (oTopNode.FullPath.Contains(strWantedNode))
{
tempnode = oTopNode;
}
else
{
BrowserNode oBN = null;
if (oTopNode.BrowserNodes.Count != 0)
{
foreach (BrowserNode oBN1 in oTopNode.BrowserNodes)
{
oBN = oBN1;
tempnode = recurseNodes(oBN, strWantedNode);
if (!(tempnode == null))
{
break;
}
}
}
else
{
tempnode = null;
}
}
return tempnode;
}