Hi all,
Could someone please tell me how to delete iLogic forms from Inventor 2013 parts/assembly using VB.net 2010?
I am able to delete all the rule using "Activated_iLogic.DeleteAllRules(PartDoc)" but "Activated_iLogic.DeleteAllForms(PartDoc)" or "Activated_iLogic.DeleteForm(PartDoc, FormName)" does not give me the result I was expecting and Google is not showing any result related to this.
Many thanks in advance.
JJ
The forms are stored in the document's attributesets. If you delete the attributeset/attribute, the form is gone.
Hi Farren,
thanks for the suggestion. I can't get it to work but that is because of my lack of understanding the API & .net skills.
Hi,
FarrenYoung means Document.AttributeSets which stores the attribute sets . Each attributeset has attributes. It allows developers to attach custom information with the document.
I checked the assembly Autodesk.iLogic.Interfaces, but I did not see the method DeleteAllForms or DeleteForm. And it looks no methods to delete forms. From where you got the two methods?
Hi Xiaodong, thanks for your reply.
I was able to delete rules and I tought that if I wanted to delete forms I needed to use the iLogic statements so that's how I came up with the 2 methods.
I have started with vb.net a couple of weeks ago and still struggling understanding the API and how to communicate with Inventor when I want something done. Replacing parts or subassemblies in an assembly took me a day to get that working. I am on a trail and error mode to get things done.
Hi,
Sorry, I still have no idea how to delete the iLogic form by code. I doubt this may be a requirement which has not been exposed.
Was looking for the same thing and found this
Hope i helps
https://www.cadlinecommunity.co.uk/hc/en-us/articles/202020531-Inventor-2015-iLogic-Delete-All-iLogi... by LukeDavenport
I see, this is an old post 🙂
in .net you need a reference to Autodesk.ilogic.core.dll
then you can use:
Imports ilc = Autodesk.iLogic.Core public class myIlogic Public Shared Sub DeleteForms(doc As Document, optional FormName a string =Nothing) Dim uiatts As New ilc.UiBuilderStorage.UiAttributeStorage(doc) For Each name In uiatts.FormNames Dim fsp = uiatts.LoadFormSpecification(name) if FormName isnot nothing if FormName.Equals(name) Then uiatts.DeleteFormSpecification(name) end if else uiatts.DeleteFormSpecification(name) End if Next End Sub end class
BR,
Daniel
Hi Daniel,
I see this is a very old post...🙈
Thank you for the code.
But how can I manipulate this code for use in iLogic?
In version 2019 this code fails. (see picture)
We really need code to delete forms from within an Inventor model.
Hi, in an iLogic rule the core would look something like this
This code should delete all forms in the current document.
AddReference "Autodesk.iLogic.Core.dll"
AddReference "Autodesk.iLogic.UiBuilderCore.dll"
Imports ilc= Autodesk.iLogic.Core
Dim doc = ThisApplication.ActiveDocument
Dim uiatts As New ilc.UiBuilderStorage.UiAttributeStorage(doc)
For Each name In uiatts.FormNames
Dim fsp = uiatts.LoadFormSpecification(name)
uiatts.DeleteFormSpecification(name)
Next
This throws me an error on inventor 2020.3.1 stating there was problem with the different Versions of the referenced Assemblies.... However, you may be lucky and there is not version-interference in the 2019-assemblies.
I couldn't find any option to turn off the version restriction in iLogic (not sure this constellation would even work in a .net-Addin).
Anyway, the code should work, if the assemblies aren't mixed up (by Autodesk)
Alternatively you may check the Attributes of the Document (since iLogic stores all its information in a document-Attributes) and delete them.... This is a real brute-force attempt but might work for your scenario:
Dim Attset As Inventor.AttributeSet
Dim doc As Inventor.Document
doc = ThisApplication.ActiveDocument
For Each Attset In doc.AttributeSets
If Attset.Name Like "iLogicInternalUi*" Then
Attset.Delete
End If
Next
as a side node, the Forms are cached, so they will still be available until the iLogic-Window isn't closed and reopened.
HTH,
Daniel
Hi Daniel,
Many thanks for this solutions!
It works for us.
You wrote "This is a real brute-force attempt.."
Sometimes we need brute force to make life more pleasant. 😉
Can't find what you're looking for? Ask the community or share your knowledge.