Use DisabledCommandTypes to turn off commands

By Wayne Brill

You may want to turn off certain commands in a document. To do this use a property on the Document called "DisabledCommandTypes". Through this property, you can disable entire classes of commands. This is a way to make a part behave similar to a part in content library. For example you could have is a  document and have Inventor UI grey-out all of the geometry modifying commands when it is the active document, but keep the File Property edit commands enabled. (the setting is saved with the document)

VB.NET example:

Sub DisableEdit()            Dim m_inventorApp As Inventor.Application            m_inventorApp = System.Runtime.                             InteropServices.Marshal.               GetActiveObject("Inventor.Application")                 Dim oDoc As Document            oDoc = m_inventorApp.ActiveDocument                 'Disable all editing commands.            oDoc.DisabledCommandTypes =                CommandTypesEnum.kShapeEditCmdType                 'Enable all editing commands.            '  oDoc.DisabledCommandTypes = 0             End Sub

 

C++ example:

void CTestDlg::OnBnClickedButton3()    {             HRESULT hr;         CComPtr Inv;             CLSID InvApplicationClsid;         hr = ::CLSIDFromProgID (L"Inventor.Application",                               &InvApplicationClsid);         //latch on to existing one         CComPtr pInvAppUnk;         hr = ::GetActiveObject             (InvApplicationClsid, NULL, &pInvAppUnk);              hr = pInvAppUnk->QueryInterface            (__uuidof(Application), (void **) &Inv);              CComPtr Doc;         hr = Inv->get_ActiveDocument(&Doc);             //Disable all feature editing commands         hr = Doc->put_DisabledCommandTypes                                (kShapeEditCmdType);          }

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading