Discussion Groups

All Discussion Groups » Autodesk DWF Viewer

Thread: How to programatically select an object with ActiveX control


Permlink Replies: 2 - Last Post: Sep 10, 2009 2:37 AM Last Post By: herbert.he Threads: [ Previous | Next ]
mspiezio

Posts: 7
Registered: 08/03/09
How to programatically select an object with ActiveX control
Posted: Aug 27, 2009 1:11 PM
  Click to reply to this thread Reply
Hi, I'm writing a .NET application to view DWF files in the ActiveX Control.
I'd like that when the user clicks a button on the form specific objects ind the DWF file are highlighted.
In the examples I've found this javascript code (see below) shows how that could be done. But I can't seem to get something like this to work in C# or VB.NET.

Thanks in advance.

function highlightObjs(str) {
objNodes = AdView.DocumentHandler.ObjectNodes;
nObjs = objNodes.Count;
for (i = 1; i <= nObjs; i++) {
node = objNodes.Item(i);

if (node)
{
node.Selected = true;
alert(node.Name);
}
}
}
mspiezio

Posts: 7
Registered: 08/03/09
Re: How to programatically select an object with ActiveX control
Posted: Aug 28, 2009 1:49 PM   in response to: mspiezio in response to: mspiezio
  Click to reply to this thread Reply
Actually I've figured out a way to do this (see below). The problem I have now is the node.name property is always blank for any object node. I know I can use node.number to reference a specific object, but I'd really would want to reference it by name, and it doesn't make sense that a name field would always be blank. In the example I downloaded from autodesk developer center, the object nodes do have a name. So what kind of object, or what setting about an object do I need to create when designing the dwg file? Or does that setting get set after a dwg file is published to a dwf file?

private void button1_Click(object sender, EventArgs e)
{
CompositeViewer = (ECompositeViewer.IAdECompositeViewer)axCExpressViewerControl.ECompositeViewer;

EPlotViewer.IAdPageViewer2 viewer = (EPlotViewer.IAdPageViewer2)CompositeViewer.DocumentHandler;
AdCommon.IAdCollection objectNodes = (AdCommon.IAdCollection)viewer.ObjectNodes;
for (int i = 1; i <= objectNodes.Count; i++)
{
EPlotRenderer.IAdPageObjectNode node = objectNodes.get__Item(i) as EPlotRenderer.IAdPageObjectNode;

if (node != null)
{
node.Selected = true;
MessageBox.Show(node.Name);
}
}
}
herbert.he

Posts: 15
Registered: 03/06/08
Re: How to programatically select an object with ActiveX control
Posted: Sep 10, 2009 2:37 AM   in response to: mspiezio in response to: mspiezio
  Click to reply to this thread Reply
Thank you for your question.

Since it seems like you are using Autodesk Design Review as a platform to build your .Net application, I propose you use API IAdContent.set_Objects instead of IAdEPlotObjectNode.Selected to select an object.

For "how to programmatically select an object with ActiveX control", you can find detailed sample code from Autodesk Design Review API documentation.

Please refer to the "Section.Content Property" section of this documentation for more information.

Please let me know if you have any follow-on questions.

-Herbert