I have heard such question a couple of times. The .NET API provided Clash, but did not expose the ability to export the viewpoint image of the clash result. In COM API, the clash result (InwOclTestResult) provides viewpoint and the method CreatePicture which should create a picture of this clash. But it looks CreatePicture does not work.
Following is a workaround which may help a bit. It gets one clash test, gets its viewpoint, creates one saved viewpoint.And it applies the saved viewpoint. Finally it exports the current view to a picture by the plug-in “lcodpimage”. Unfortunately, the image has NOT the information to show (highlight) the clash entities as what you can see from UI.
// export the viewpoint image of clash result public void exportClashViewPoint() { ComApi.InwOpState10 oState; oState = ComBridge.State; //find the clash detective plugin 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) { System.Windows.Forms.MessageBox.Show( "cannot find clash test plugin!"); return; } //Run all clash test or specific clash //or assume the UI has the results already //m_clash.RunAllTests(null); // get the plug-in of exporting image ComApi.InwOaPropertyVec options = oState.GetIOPluginOptions("lcodpimage"); // set to the format to png foreach (ComApi.InwOaProperty opt in options.Properties()) { if (opt.name == "export.image.format") opt.value = "lcodpexpng"; } try { // get the first Test and its first clash result ComApi.InwOclClashTest clashTest = m_clash.Tests()[1]; ComApi.InwOclTestResult clashResult = clashTest.results()[1]; // create a temporary saved viewpoint ComApi.InwOpView oSV = oState.ObjectFactory( ComApi.nwEObjectType.eObjectType_nwOpView); oSV.name = "temp-view"; oSV.anonview.ViewPoint = clashResult.GetSuitableViewPoint().Copy(); oState.SavedViews().Add(oSV); // apply the temp saved viewpoint oState.ApplyView(oState.SavedViews().Last()); // export it to an image string tempFileName = "c:\temp\" + clashTest.name + "- " + clashResult.name + ".PNG"; oState.DriveIOPlugin( "lcodpimage", tempFileName, options); // delete the temp saved viewpoint oState.SavedViews().RemoveLast(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }

Leave a Reply to Wolfgang WehCancel reply