Creating clash detective shortcuts with api

Creating clash detective shortcuts with api

Anonymous
Not applicable
3,411 Views
10 Replies
Message 1 of 11

Creating clash detective shortcuts with api

Anonymous
Not applicable

I am new to the Navisworks API and am trying to create shortcuts to functions in the clash detective so that we can add them too the quick access tool bar, so that we can have them assigned to hot keys. (kinda a round about way but since I haven't been able to find how to just add it straight from clash detective I thought I would explore this option). Basically I would like to know how to exicute functions like "Dim/Hide others" in the display settings of clash detective, or "Group Selected Clashes" and "Explode Group" with a Addin Plugin so that it can be added to the quick access toolbar.

 

Is this possible? any help would be greatly appreciated.

 

Thanks

0 Likes
3,412 Views
10 Replies
Replies (10)
Message 2 of 11

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

A coupld of options that you can place your AddInPlugin (a snapshpot is attached), but I do not see an option for Quick Access.  Howeverm if you want to have a group of your own buttons, the Ribbon plugin can help you. Some blogs are available:

 

http://adndevblog.typepad.com/aec/2012/07/custom-ribbon-of-navisworks-part-1.html

http://adndevblog.typepad.com/aec/2012/07/custom-ribbon-of-navisworks-part-2.html

 

 

 

1.png

 

about execute command, there is not an API that can execute Navisworks commands. you will have write some codes in your button execution. e.g. 

 

Dim/Hide others: give a clashresult, you can get ClashResult.Item1 and ClashResult.Item2. they are the first leaf geometry of a clash result. then get other model items, then call DocumentModels.OverridePermanentTransparency (other model items)

 

as to group selected clashes, you will need to get those clash results, and call DocumentClashTests.TestsRemove them to a folder.

 

I'd recommend with some blogs on ClashTest for you to get started with:

http://adndevblog.typepad.com/aec/2012/05/navisworks-net-api-2013-new-feature-clash-1.html

http://adndevblog.typepad.com/aec/2012/05/navisworks-net-api-2013-new-feature-clash-2.html

 

Hope these help.

 

0 Likes
Message 3 of 11

Anonymous
Not applicable

Thanks for the reply, I will look into these articles and give it a shot. It sounds like these will point me in the right direction, though I was starting to get to the conclusion that I would have to write the code and that there wasn't just a way to exicute Navisworks commands. I will post my finding and any other questions that I run into.

 

Thanks again.

0 Likes
Message 4 of 11

jmlovelace
Enthusiast
Enthusiast

Late to the party, came across this as I was looking for something else...but this is something I have tried to do in the past through the API, and although it can technically be done, it is very slow to execute making it impractical. A workaround is to use AutoHotkey to drive a mouse to click the buttons, but this requires setting the Clash Detective window to a fixed resolution. That being said I did this for my setup and it is super efficient. I made hotkeys for Dim/Hide Other and Set Selected Element Clashes to Reviewed/Approved

0 Likes
Message 5 of 11

xiaodongliang
Contributor
Contributor

 Hi @jmlovelace,

 

sorry, I got confused with your update. The original post talked about the shortcut of clash detective, while you seemed to be talking about the performance of the performance? And I do not either understand what the scenario is with 'fixed resolution'.

 

Could you provide a bit more information and necessary snapshots? It would help to know what could be a workaround/solution.

 

0 Likes
Message 6 of 11

jmlovelace
Enthusiast
Enthusiast

My concern when I looked into this was creating a few hotkey commands: Dim/Hide Other and Mark Clashes of Selected Items as Reviewed or Approved (similar result to box-selecting model items, filtering to Inclusive on the clash detective window, selecting all clashes, and changing status to Reviewed or Approved). What I found is that although these could technically be implemented through the API through the suggested solution above, it is a much slower process because it must iterate through each model item individually.

 

The workaround I made is definitely not ideal, but with some tweaking it can work on anyone's system. I wrote a few scripts using AutoHotKey (https://autohotkey.com) that literally take control of the mouse, press buttons on the clash detective window, then return the mouse back to the user. Because the script bases the mouse coordinates off the top left of the clash detective window, the buttons must stay in a fixed position relative to the top left of the window. Code is below (to use it you will have to tweak the mouse coordinates to match your clash detective window. You can identify the coordinates using the included Window Spy tool).

 

#SingleInstance force
#NoEnv
#Persistent
SetTitleMatchMode 2
SetDefaultMouseSpeed, 0
#IfWinExist Autodesk Navisworks Manage
;Numpad1::
;Numpad2::
;Numpad3::
;Numpad4::
;Numpad5::
;Numpad6::
;Numpad7::
;Numpad8::
;Numpad9::
;Numpad0::
;NumpadDot::
;NumpadEnter::
NumpadAdd:: ;Dim Other
	GetKeyState NumL, NumLock, T
	if NumL = D
	{
		SendRaw +
		return
	}
	else
	MouseGetPos, X, Y, Window
	WinActivate Clash Detective
	Click 515,284
	WinActivate, ahk_id %Window%
	MouseMove, %X%, %Y%
return
NumpadSub:: ;Refresh
	GetKeyState NumL, NumLock, T
	if NumL = D
	{
		SendRaw +
		return
	}
	else
	MouseGetPos, X, Y, Window
	WinActivate Clash Detective
	Click 492,235
	WinActivate, ahk_id %Window%
	MouseMove, %X%, %Y%
return
NumpadDiv:: ;Mark Reviewed
	GetKeyState NumL, NumLock, T
	if NumL = D
	{
		SendRaw +
		return
	}
	else
	MouseGetPos, X, Y, Window
	WinActivate Clash Detective
	Click 449,127
	Sleep, 100
	Click 449,254
	Sleep, 500
	Click 37,191
	Send {Esc}
	Send ^{End}
	Send +{PgUp 20}
	Click 230,192
	Sleep, 500
	Click 188,246
	Sleep, 700
	Click 472,127
	Sleep, 700
	Click 439,161
	WinActivate, ahk_id %Window%
	MouseMove, %X%, %Y%
return
NumpadMult:: ;Mark Approved
GetKeyState NumL, NumLock, T
	if NumL = D
	{
		SendRaw +
		return
	}
	else
	MouseGetPos, X, Y, Window
	WinActivate Clash Detective
	Click 449,127
	Sleep, 100
	Click 449,254
	Sleep, 500
	Click 37,191
	Send {Esc}
	Send ^{End}
	Send +{PgUp 20}
	Click 230,192
	Sleep, 500
	Click 188,262
	Sleep, 700
	Click 472,127
	Sleep, 700
	Click 439,161
	WinActivate, ahk_id %Window%
	MouseMove, %X%, %Y%
return	

It would definitely be helpful to add support for commands in the clash detective window to the API, as well as custom hotkey support, for a more direct solution. Hope this helps.

 

Jake

Message 7 of 11

xiaodongliang
Contributor
Contributor

Hi @jmlovelace,

 

sorry for my late response. 

 

I am ignorant with such technology AutoHotKey. It looks interesting, however I have not got why it could be more efficient than APIs. Please bear with me try to understand. 

basically speaking, I think your workflow contains two sections:

 

1. Dim/Hide other:

this can be done by the code that does not need to iterate each model item:

http://adndevblog.typepad.com/aec/2012/06/focusing-on-a-selected-item-and-hide-all-others-using-navi...

2. Mark Clashes of Selected Items as Reviewed or Approved:

   no matter how the items are selected, but they are only ClashResult , right? it might not be strict, but the volumes of ClashResult would probably much less than than volumes of model items.  Do you mean this section would cause much time?  While you are talking about selection items by windows of mouse dragging, which is a bit confusing to me what the scenario is.  I'd think this is a case of product feature I have never noticed.

 

After knowing better, I can log a wish with our engineer team.

Thank you.

 

 

 

 

 

0 Likes
Message 8 of 11

jmlovelace
Enthusiast
Enthusiast

Video below shows the process my script automates. This is useful for bulk processing clashes. As far as the Navisworks API is concerned, it would be great to have access to the currently selected clash results in the clash detective window, as well as a way to programmatically toggle dim/hide other.

 

The script in the link you posted only hides others for a selected model item. Using a similar process to dim/hide others for a particular clash test, as the native button does, as well as replicate the wireframe display of dim other and set modelitems to correct colors would take some time to process, and seems unnecessary when the Dim/Hide Other buttons do it well enough.

 

0 Likes
Message 9 of 11

Anonymous
Not applicable

@jmlovelace wrote:

Video below shows the process my script automates. This is useful for bulk processing clashes. As far as the Navisworks API is concerned, it would be great to have access to the currently selected clash results in the clash detective window, as well as a way to programmatically toggle dim/hide other.

 

The script in the link you posted only hides others for a selected model item. Using a similar process to dim/hide others for a particular clash test, as the native button does, as well as replicate the wireframe display of dim other and set modelitems to correct colors would take some time to process, and seems unnecessary when the Dim/Hide Other buttons do it well enough.

 


Hey Jm,  Do you know if there would be a way to add a "calibration"/ auto "grab" the coordinates into the AHK script?  It seems that implementing a GUI isn't very difficult for the scripts, I'm just trying to come up with a solution I can send to anyone else running Navisworks and have it be "deployable" without having to explain using window spy to find coordinates.  And then if the windows ever get stretched/moved, etc you could just re-calibrate it.

 

There's a couple of us in the "General" Navisworks forum that had found a AHK script from 2011, but ...

 

0 Likes
Message 10 of 11

Anonymous
Not applicable

So last night I was snooping around in Visual Basic at the Navisworks files, and my issue is I'm not exactly sure how the software references things.  I believe ${clash} references the Clash.dll (not sure exactly what it was called) but when I got to reading through the .NAME files, there seemed to be a lot of interesting things there.  The names here are the same format as the RoamerCommands.XML, but I'm not sure how to go about referencing the Clash tool identities in the RoamerCommands.XML

 

E.G. Clash_Detect_Tool_Input_6=

Dim Others

 

But I'm not sure how I can go about setting up a file that references the same actionable items/names in a project.

 

Just thought I'd keep on brainstorming.  If there's a good tutorial on setting up a "New Project" in Visual Basic for the Navis .API, i'd appreciate it, or any other input!

0 Likes
Message 11 of 11

jmlovelace
Enthusiast
Enthusiast

Great find! After perusing google some I finally found our missing link. This guys walks through how to use the roamer commands in the Api through the Interop: https://houseofbim.com/2017/05/21/naviworks-net-executecommand-method/

 

Below is a basic AddInPlugin I made to demonstrate this, written in C#:

using Autodesk.Navisworks.Api.Plugins;
using static Autodesk.Navisworks.Api.Interop.LcRmFrameworkInterface;

namespace TestCommand1
{
    [PluginAttribute("TestCommand", //Plugin name
                    "BGVC", //Developer ID or GUID
                    ToolTip = "Test",
                    //The tooltip for the item in the ribbon
                    DisplayName = "Test Command")]
    //Display name for the Plugin in the Ribbon

    //  Specify the location of the plug-in
    //[AddInPlugin(AddInLocation.Help)]
    //[AddInPluginAttribute(AddInLocation.CurrentSelectionContextMenu)]
    public class TestAddIn : AddInPlugin
    {
        public override int Execute(params string[] parameters)
        {
            ExecuteCommand("RoamerGUI_OM_MODE_WALK”", Autodesk.Navisworks.Api.Interop.LcUCIPExecutionContext.eTOOLBAR);

            return 0;
        }
    }
}

Still need to figure out how to execute clash detective commands

0 Likes