Ilogic - Delete Iproperties

Ilogic - Delete Iproperties

j.wolbers-NoTech
Enthusiast Enthusiast
2,272 Views
13 Replies
Message 1 of 14

Ilogic - Delete Iproperties

j.wolbers-NoTech
Enthusiast
Enthusiast

Hi,

 

Is it possible to remove all Iproperties from the Summary and Project tab with an ILogic code? I now do this manually with purchase parts that we import into our system. Ideally, the code should also immediately remove everything from underlying parts if it is an assembly.

 

Look forward to hearing whether this is possible.

 

Kinds regards,

Jeffrey

0 Likes
Accepted solutions (1)
2,273 Views
13 Replies
Replies (13)
Message 2 of 14

marcin_otręba
Advisor
Advisor

You can start from something like:

 

 

Dim ass As AssemblyDocument= ThisDoc.Document
Dim j As Integer
Dim i As Integer
For i = 1 To  ass.PropertySets.Count
If ass.PropertySets.Item(i).Name = "Design Tracking Properties" Or ass.PropertySets.Item(i).Name = "Inventor Summary Information" Then

	For j = 1 To  ass.PropertySets.Item(i).Count
		Try
			ass.PropertySets.Item(i).Item(j).Value = ""
		Catch
		End Try
		
		Next
End If	
Next
Dim doc As Document
For Each doc In ass.AllReferencedDocuments

For i = 1 To  doc.PropertySets.Count
If doc.PropertySets.Item(i).Name = "Design Tracking Properties" Or doc.PropertySets.Item(i).Name = "Inventor Summary Information" Then

	For j = 1 To  doc.PropertySets.Item(i).Count
		Try
			doc.PropertySets.Item(i).Item(j).Value = ""
		Catch
		End Try
		
		Next
End If	
Next
Next

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 3 of 14

Martin-Winkler-Consulting
Advisor
Advisor

@j.wolbers-NoTech 

Yes it is possible!

Copy this iLogic Code in one rule and run it:

Sub Main
	Dim oDoc As Document = ThisDoc.Document
	If  oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject
		Dim oPropSet As PropertySet
		For Each oPropSet In oDoc.PropertySets
		If oPropSet.Name = "Design Tracking Properties" Or
			oPropSet.Name = "Inventor Summary Information" Then
			Delete_PropSet_Contents(oPropSet)
		End If
		Next
	Else 
		MsgBox("Start only in Assembly", vbCritical, "Delete Content iProperties")
	End If
	Dim oRefDoc As Document
	For Each oRefDoc In oDoc.AllReferencedDocuments
		GetRefDocs(oRefDoc)
	Next
End Sub

Sub GetRefDocs (oDoc As Document)
	Dim oPropSet As PropertySet
	For Each oPropSet In oDoc.PropertySets
		If oPropSet.Name = "Design Tracking Properties" Or
			oPropSet.Name = "Inventor Summary Information" Then
			Delete_PropSet_Contents(oPropSet)
		End If
	Next
End Sub

Sub Delete_PropSet_Contents(oPropSet As PropertySet)
	Dim oProp As [Property]
	For Each oProp In oPropSet
		Try
		oProp.Value = ""
		Catch
		End Try
	Next
End Sub

 

Martin Winkler
CAD Developer
Did you find this post helpful? Feel free to like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature

0 Likes
Message 4 of 14

j.wolbers-NoTech
Enthusiast
Enthusiast

Hi @Martin-Winkler-Consulting & @marcin_otręba 

 

Both Ilogic codes work.
No idea which one to use best.., I don't think it matters.

 

However, I have two more minor issues ...

  • The iLogic code does not work if you run it on a part (with an assembly and the underlying daughters it works).
  • Two more Iproperty fields remain filled in (see image)

 

1.PNG

 

Kinds regards,

Jeffrey

0 Likes
Message 5 of 14

marcin_otręba
Advisor
Advisor
Accepted solution

hi,

 

they are not deleted because they are in "Inventor Document Summary Information" property set.

 

corrected ilogic (it will remove from single document as well):

 

If   ThisDoc.Document.SubType="{E60F81E1-49B3-11D0-93C3-7E0706000000}" Then
Dim ass As AssemblyDocument = ThisDoc.Document
Dim j As Integer
Dim i As Integer
For i = 1 To  ass.PropertySets.Count
If ass.PropertySets.Item(i).Name = "Design Tracking Properties" Or ass.PropertySets.Item(i).Name = "Inventor Summary Information" Or ass.PropertySets.Item(i).Name = "Inventor Document Summary Information" Then

	For j = 1 To  ass.PropertySets.Item(i).Count
		Try
			ass.PropertySets.Item(i).Item(j).Value = ""
		Catch
		End Try
		
		Next
End If	
Next
Dim doc As Document
For Each doc In ass.AllReferencedDocuments

For i = 1 To  doc.PropertySets.Count
If doc.PropertySets.Item(i).Name = "Design Tracking Properties" Or doc.PropertySets.Item(i).Name = "Inventor Summary Information" Or ass.PropertySets.Item(i).Name = "Inventor Document Summary Information" Then

	For j = 1 To  doc.PropertySets.Item(i).Count
		Try
			doc.PropertySets.Item(i).Item(j).Value = ""
		Catch
		End Try
		
		Next
End If	
Next
Next
Else If ThisDoc.Document.SubType <> "{E60F81E1-49B3-11D0-93C3-7E0706000000}" Then
	For i = 1 To  ThisDoc.Document.PropertySets.Count
If ThisDoc.Document.PropertySets.Item(i).Name = "Design Tracking Properties" Or ThisDoc.Document.PropertySets.Item(i).Name = "Inventor Summary Information" Or ThisDoc.Document.PropertySets.Item(i).Name = "Inventor Document Summary Information" Then

	For j = 1 To  ThisDoc.Document.PropertySets.Item(i).Count
		Try
			ThisDoc.Document.PropertySets.Item(i).Item(j).Value = ""
		Catch
		End Try
		
		Next
End If	
Next
End If

 

 

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 6 of 14

j.wolbers-NoTech
Enthusiast
Enthusiast

@marcin_otręba 

 

Thank you very much for your help!

 

Regards,
Jeffrey

0 Likes
Message 7 of 14

J.Classens
Enthusiast
Enthusiast

This ilogic rule works perfect! 

 

I can't adjust it the way i like it.

I want this rule to work only to childeren in an assembly. 

 

Is it possible to adjust this rule to get it work like that?

0 Likes
Message 8 of 14

marcin_otręba
Advisor
Advisor

do you mean that you want to delete only in first level of assembly components, or you do not want to delete properties in assembly itself?

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 9 of 14

marcin_otręba
Advisor
Advisor

if you want to skip iproperties in assembly just delete :

 

If   ThisDoc.Document.SubType="{E60F81E1-49B3-11D0-93C3-7E0706000000}" Then
Dim ass As AssemblyDocument = ThisDoc.Document
Dim j As Integer
Dim i As Integer
'-------------------------------------------------delete from here
For i = 1 To ass.PropertySets.Count If ass.PropertySets.Item(i).Name = "Design Tracking Properties" Or ass.PropertySets.Item(i).Name = "Inventor Summary Information" Or ass.PropertySets.Item(i).Name = "Inventor Document Summary Information" Then For j = 1 To ass.PropertySets.Item(i).Count Try ass.PropertySets.Item(i).Item(j).Value = "" Catch End Try Next End If Next
'-----------------------------------------------------to her to leave iprop in assembly
Dim doc As Document For Each doc In ass.AllReferencedDocuments For i = 1 To doc.PropertySets.Count If doc.PropertySets.Item(i).Name = "Design Tracking Properties" Or doc.PropertySets.Item(i).Name = "Inventor Summary Information" Or ass.PropertySets.Item(i).Name = "Inventor Document Summary Information" Then For j = 1 To doc.PropertySets.Item(i).Count Try doc.PropertySets.Item(i).Item(j).Value = "" Catch End Try Next End If Next Next Else If ThisDoc.Document.SubType <> "{E60F81E1-49B3-11D0-93C3-7E0706000000}" Then For i = 1 To ThisDoc.Document.PropertySets.Count If ThisDoc.Document.PropertySets.Item(i).Name = "Design Tracking Properties" Or ThisDoc.Document.PropertySets.Item(i).Name = "Inventor Summary Information" Or ThisDoc.Document.PropertySets.Item(i).Name = "Inventor Document Summary Information" Then For j = 1 To ThisDoc.Document.PropertySets.Item(i).Count Try ThisDoc.Document.PropertySets.Item(i).Item(j).Value = "" Catch End Try Next End If Next End If

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 10 of 14

J.Classens
Enthusiast
Enthusiast

@marcin_otręba 

 

Thanks! This was exactly what i meant. 

 

The iLogic rule works perfect for me now. 

0 Likes
Message 11 of 14

J.Classens
Enthusiast
Enthusiast

We are working with this ilogic for a while and it works almost perfect for our use.

I added some extra lines to complete the ilogic rule for our use.

 

After clearing the properties in underlying parts i want to ad to the title a predifined text. 
I use this part to do it. 

 

If   ThisDoc.Document.SubType="{E60F81E1-49B3-11D0-93C3-7E0706000000}" Then
Dim ass As AssemblyDocument = ThisDoc.Document
Dim j As Integer
Dim i As Integer

Dim doc As Document
For Each doc In ass.AllReferencedDocuments

For i = 1 To  doc.PropertySets.Count
If doc.PropertySets.Item(i).Name =  "Inventor Summary Information"  Then

	For j = 1 To  doc.PropertySets.Item(i).Count
		Try
			doc.PropertySets.Item(i).Item(j).Value = "Sub part"
		
		Catch
		End Try
				
		Next 
End If	
Next
Next
End If

 

 The only problem is that it changed the properties of the complete propertyset.

Is it possible to change only the Title property? 

0 Likes
Message 12 of 14

K.TRYFONIDIS
Advocate
Advocate

Hello,

 

Is it possible to get a code to run it only inside part enviroment ? i would like to clean summary, project, status and custom tab.

 

Is it doable?


Thanks

0 Likes
Message 13 of 14

marcin_otręba
Advisor
Advisor

 

yes it is.

 

You can find information about:

properties here: 

https://knowledge.autodesk.com/search-result/caas/simplecontent/content/list-all-iproperties-and-how....

about subtypes here:

 

https://adndevblog.typepad.com/manufacturing/2013/01/inventor-document-sub-types.html

 

it will be only problem with project and status tab because there is no such property set they are only showed in project and status tabs but parent propertyset named "Design Tracking Properties" is much bigger :

marcin_otrba_0-1657270371380.png

 

 

so to accomplish that you can use simple loop like:

 

marcin_otrba_1-1657270436434.png

it will cleanup  summary and remove all custom iproperties.

 

to clean project and status you need to do it like this:

 

prop_set = doc.PropertySets.Item("Design Tracking Properties")
prop_set.Item("name of property to clean up").Value=""

also when you have ipropert with date format then you need to set some date not to clean it up like here:

 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/vba-change-quot-creation-date-quot-i...

 

so to sum this up here is the code wit only some samples of cleaning project and status tabs:

 

 

'"4D29B490-49B2-11D0-93C3-7E0706000000" - part
'"9C464203-9BAE-11D3-8BAD-0060B0CE6BB4" sheet metal
If ThisDoc.Document.SubType = "{4D29B490-49B2-11D0-93C3-7E0706000000}" Or ThisDoc.Document.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
Dim doc As PartDocument = ThisDoc.Document
Dim prop_set As PropertySet = doc.PropertySets.Item("Inventor Summary Information")

For i = 1 To prop_set.Count
	prop_set.Item(i).Value=""
Next

prop_set  = doc.PropertySets.Item("Inventor Document Summary Information")
For i = 1 To prop_set.Count
	prop_set.Item(i).Value=""
Next
If doc.PropertySets.Item("Inventor User Defined Properties").Count > 0 Then
	
prop_set = doc.PropertySets.Item("Inventor User Defined Properties")
Dim count As Integer= prop_set.Count
For i =0 To count
	Try
		prop_set.Item(count-i).Delete
		Catch
	End Try
	
Next
End If
' project and status tabs properties clean up:
prop_set = doc.PropertySets.Item("Design Tracking Properties")
prop_set.Item("Project").Value = ""
prop_set.Item("Description").Value = ""
prop_set.Item("Part Number").Value = ""
prop_set.Item("Checked By").Value = ""
prop_set.Item("Date Checked").Value="01.01.0001"

End If

 

marcin.

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 14 of 14

marcin_otręba
Advisor
Advisor
ThisDoc.Document.PropertySets.Item("Inventor Summary Information").Item("Title").Value=""

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes