Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

always cannot find clash test plugin?

2 REPLIES 2
Reply
Message 1 of 3
martinkaifa
498 Views, 2 Replies

always cannot find clash test plugin?

why m_clash variable is always empty???????

No matter what file, the results are the same.

 

 

public void GetClashDetail() {

ComApi.InwOpState10 oState;
oState = ComApiBridge.ComApiBridge.State;
ComApi.InwOpClashElement m_clash = null;
foreach (ComApi.InwBase oPlugin in oState.Plugins())
{
if (oPlugin.ObjectName == "nwOpClashElement")
{
m_clash = (ComApi.InwOpClashElement)oPlugin;
break;
}
}
if (m_clash == null) //m_clash is always empty ??????
{
System.Windows.Forms.MessageBox.Show("cannot find clash test plugin!");
return;

}
ComApi.InwOclClashTest oNewTest = (ComApi.InwOclClashTest)oState.ObjectFactory(Autodesk.Navisworks.Api.Interop.ComApi.nwEObjectType.eObjectType_nwOclClashTest, null, null);
oNewTest.name = "Mytest";
oNewTest.status = Autodesk.Navisworks.Api.Interop.ComApi.nwEClashTestStatus.eClashTestStatus_NEW;
m_clash.Tests().Add(oNewTest);


}

Tags (2)
2 REPLIES 2
Message 2 of 3
martinkaifa
in reply to: martinkaifa

I'm sorry,I should add that,it not a Plugin,it is a C# desktop program.

all the code:

 


using Autodesk.Navisworks.Api.Controls;
using ComApi = Autodesk.Navisworks.Api.Interop.ComApi;
using ComApiBridge = Autodesk.Navisworks.Api.ComApi;
using ComBridge = Autodesk.Navisworks.Api.ComApi.ComApiBridge;
using Autodesk.Navisworks.Api.Interop.ComApi;
using Autodesk.Navisworks.Api.Clash;
using Autodesk.Navisworks.Api.Automation;
using Autodesk.Navisworks.Api;

namespace NavisworksDemo
{
public partial class Form1 : Form
{
ViewControl VC;
DocumentControl DC;

public Form1()
{
InitializeComponent();
if (this.components == null)
{
this.components = new System.ComponentModel.Container();
}
VC = new ViewControl();
DC = new DocumentControl(this.components);

VC.DocumentControl = DC;
VC.Dock = DockStyle.Fill;
//VC.Location = new Point(Left + 10, Top - 10);
VC.Name = "myVC";
VC.Size = new System.Drawing.Size(750, 750);

this.Controls.Add(VC);

DC.SetAsMainDocument();


}
//open
private void tSMIOpenFile_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
DC.Document.TryOpenFile(ofd.FileName);
DC.Document.Tool.Value = Tool.Select;
}


}
//clash test event
private void tsmiClash_Click(object sender, EventArgs e)
{
Cla****erateResults();
}

void Cla****erateResults()
{

ComApi.InwOpState10 oState;
oState = ComApiBridge.ComApiBridge.State;

//find the clash detective plugin
ComApi.InwOpClashElement m_clash = null;
foreach (ComApi.InwBase oPlugin in oState.Plugins())
{
if (oPlugin.ObjectName == "nwOpClashElement")//no find InwOpClashElement
{
m_clash = (ComApi.InwOpClashElement)oPlugin;
break;
}
}
if (m_clash == null)//Always is null
{
System.Windows.Forms.MessageBox.Show("cannot find clash test plugin!");
return;
}
ComApi.InwOclClashTest oNewTest = (ComApi.InwOclClashTest)oState.ObjectFactory(Autodesk.Navisworks.Api.Interop.ComApi.nwEObjectType.eObjectType_nwOclClashTest, null, null);
oNewTest.name = "Mytest";
oNewTest.status = Autodesk.Navisworks.Api.Interop.ComApi.nwEClashTestStatus.eClashTestStatus_NEW;

m_clash.Tests().Add(oNewTest);


}

}

}

Message 3 of 3

Hi martinkaifa,

.NET control based application cannot access Clash/Timeliner APIs. Sorry if this is a bad news for you.

If you want to get the clash info, you could workaround it by starting an automation behind the scene and invoke the relevant plugin which gets clash info, and transfer the data to your application. It is not elegant, but can help a bit.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report