ilogic - Copy iproperties from assembly to various parts

ilogic - Copy iproperties from assembly to various parts

Anonymous
Not applicable
4,448 Views
30 Replies
Message 1 of 31

ilogic - Copy iproperties from assembly to various parts

Anonymous
Not applicable

Hi.

I have an issue and couldn't find an exact answear.

 

I want to copy iproperty value form assembly to all sub-components (assemblies, parts and parts of asemblies).

Amount of this sub-components is various.

Names of this sub-components are various.

There can be many levels of assemblies.

I want this ilogic rule to be run from main assembly.

This iproperty might be a custom property (let's name it NR).

 

Could You help please?

 

 

0 Likes
Accepted solutions (1)
4,449 Views
30 Replies
Replies (30)
Message 21 of 31

Anonymous
Not applicable

If you keep your purchased items in your Library (defined in Project) then this code will do exactly what you want.

Or maybe you would like an another approach?

0 Likes
Message 22 of 31

Anonymous
Not applicable

That will do what you want if you keep your purchased items in Library (defined in Porject).

Or maybe you want an another approach?

Please try my code and tell if it works.

(Sorry for two answers in a row - dodn't see that new page was created)

0 Likes
Message 23 of 31

tecnico
Contributor
Contributor

First error(Ita):    iProperties: impossibile trovare la proprietà denominata "NR".

0 Likes
Message 24 of 31

Anonymous
Not applicable

I added two codes.

First one is for you - it will populate "Project" property from your Input to all subcomponents.
Second is refered to custom properties - i added it because it was primary objective of this topic.

Try first code.

0 Likes
Message 25 of 31

nivyus
Contributor
Contributor
体积改成密度无法实现,是哪里不对吗。
0 Likes
Message 26 of 31

tecnico
Contributor
Contributor

Unfortunately I am not yet experienced enough to distinguish a first part from a second, could you kindly send me the complete rule that can work without needing to modify it? thanks a lot

0 Likes
Message 27 of 31

Anonymous
Not applicable

I did it already.

Did you try this code?

iProperties.Value("Project", "Project") = InputBox("Riferimento al progetto", "Progetto", "Default Entry")

	Dim oAssyDoc As AssemblyDocument = ThisApplication.ActiveDocument
    Dim AllRefDocs As DocumentsEnumerator = oAssyDoc.AllReferencedDocuments
    Dim oDoc As Inventor.Document = Nothing
	Dim oProjectMgr As DesignProjectManager = ThisApplication.DesignProjectManager
	Dim CCPath As String = oProjectMgr.ActiveDesignProject.ContentCenterPath
	Dim i As Integer
	Dim isCC As Boolean = False
	Dim isLibrary As Boolean = False

        Dim strNR as string = iProperties.Value("Project", "Project")
        
    For Each oDoc In AllRefDocs
		
		For i = 1 To oProjectMgr.ActiveDesignProject.LibraryPaths.Count
			If oDoc.FullFileName.Contains(oProjectMgr.ActiveDesignProject.LibraryPaths.Item(i).Path) = True Then 
				isLibrary = True
				Exit For
				End If
		Next
		
		If oDoc.FullFileName.Contains(CCPath) = True Then
			isCC = True
		End If
			
		If isCC = False And isLibrary = False Then

	        Dim invDesignInfo As PropertySet
	        invDesignInfo = oDoc.PropertySets.Item("Design Tracking Properties")

	        Dim invProjectProperty As [Property]
	        invProjectProperty = invDesignInfo.Item("Project")

	        invProjectProperty.Value = strNR
		End If
		
    	isCC = False
		isLibrary = False
    Next

 

0 Likes
Message 28 of 31

tecnico
Contributor
Contributor

The rule works great !!!!
only now I would like to know if it is possible to do it also for the "Title" parameter and if it is possible to leave out the components that are purchased in the bill, and obviously all the sub-parts present in these. Anyway thank you very much already so it is a huge step forward

0 Likes
Message 29 of 31

Anonymous
Not applicable

Try if it works

iProperties.Value("Project", "Project") = InputBox("Riferimento al progetto", "Progetto", "Default Entry")
iProperties.Value("Summary", "Title") = InputBox("Riferimento al titolo", "Titolo", "Default Entry")
	Dim oAssyDoc As AssemblyDocument = ThisApplication.ActiveDocument
    Dim AllRefDocs As DocumentsEnumerator = oAssyDoc.AllReferencedDocuments
    Dim oDoc As Inventor.Document = Nothing
	Dim oProjectMgr As DesignProjectManager = ThisApplication.DesignProjectManager
	Dim CCPath As String = oProjectMgr.ActiveDesignProject.ContentCenterPath
	Dim i As Integer
	Dim isCC As Boolean = False
	Dim isLibrary As Boolean = False
	Dim isPurchased As Boolean = False

        Dim strNR As String = iProperties.Value("Project", "Project")
		Dim strTit As String = iProperties.Value("Summary", "Title")
      
    For Each oDoc In AllRefDocs
		For i = 1 To oProjectMgr.ActiveDesignProject.LibraryPaths.Count
			If oDoc.FullFileName.Contains(oProjectMgr.ActiveDesignProject.LibraryPaths.Item(i).Path) = True Then 
				isLibrary = True
				Exit For
				End If
		Next
		
		If oDoc.FullFileName.Contains(CCPath) = True Then
			isCC = True
		End If
		
		If oDoc.ComponentDefinition.BomStructure = 51973 Then
			isPurchased = True
		End If
			
		If isCC = False And isLibrary = False And isPurchased = False Then

	        Dim invDesignInfo As PropertySet
	        invDesignInfo = oDoc.PropertySets.Item("Design Tracking Properties")

	        Dim invProjectProperty As [Property]
	        invProjectProperty = invDesignInfo.Item("Project")
			
			Dim invSummaryInfo As PropertySet
	        invSummaryInfo = oDoc.PropertySets.Item("Inventor Summary Information")
			
			Dim invTitleProperty As [Property]
	        invTitleProperty = invSummaryInfo.Item("Title")

	        invProjectProperty.Value = strNR
			invTitleProperty.Value = strTit
		End If
		
    	isCC = False
		isLibrary = False
		isPurchased = False
    Next
Message 30 of 31

tecnico
Contributor
Contributor

PERFECT.

0 Likes
Message 31 of 31

Anonymous
Not applicable

I think this long topic deserves closing

0 Likes