Get iLogic forms in a document

Get iLogic forms in a document

gustavo.cassel
Advocate Advocate
412 Views
1 Reply
Message 1 of 2

Get iLogic forms in a document

gustavo.cassel
Advocate
Advocate

Hello, i'm developing an C# addin for Inventor 2023.

I've already managed a way to get all the rules in a determined document and remove each one.

I want a way to get all existing forms in the document and delete.

Here is what I already have:

const string iLogicAddinGuid = "{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}";
Inventor.ApplicationAddIn addin;

try
{
    addin = Global.InventorApplication.ApplicationAddIns.get_ItemById(iLogicAddinGuid);
}
catch
{ return; }

Document document = Global.InventorApplication.ActiveDocument;

if (addin != null)
{
    if (!addin.Activated)
        addin.Activate();
    dynamic automation = addin.Automation;
    System.Collections.IEnumerable ruleCol = automation.get_Rules(document);
    if (ruleCol is null)
    {
        MessageBox.Show("empty");
        return;
    }
    else
    {
        foreach (dynamic item in ruleCol)
        {
            MessageBox.Show(item.Name);
        }
        automation.DeleteAllRulesInDocument(document);
    }
}
0 Likes
Accepted solutions (1)
413 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor
Accepted solution

Hi @gustavo.cassel.  The specifications for internal iLogic forms are stored in Bit Arrays within document level Attributes.  So you can delete them by deleting the AttributeSet(s) that hold their data.  Here is a link to a related post.  And here is a simple vb.net example code for deleting all internal iLogic forms from the active document.

Dim oDoc As Document = ThisApplication.ActiveEditDocument
Dim oASets As AttributeSets = oDoc.AttributeSets
If oASets.Count = 0 Then Logger.Info("No AttributeSets") : Exit Sub
For Each oASet As AttributeSet In oASets
	'the AttributeSet.Name should start with "iLogicInternalUi"
	If oASet.Name Like "iLogicInternalUi*" Then oASet.Delete
Next
'toggle visibility of iLogic dockable window to update it
For Each oDW As Inventor.DockableWindow In ThisApplication.UserInterfaceManager.DockableWindows
	If oDW.InternalName = "ilogic.treeeditor" Then
		oDW.Visible = False
		oDW.Visible = True
	End If
Next

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes