Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reading parameter

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
pbartosinski
602 Views, 4 Replies

Reading parameter

pbartosinski
Enthusiast
Enthusiast

Hi

 

Little help please. I would like to read some numeric value parameters and sum it up. I have a assembly which contains parts and sub assemblies. Some od them have parameter "wool". I would like to sum it up and place numeric value to parameter "sum_wool" in main assembly. 

 

Any ideas? Some ilogic?

0 Likes

Reading parameter

Hi

 

Little help please. I would like to read some numeric value parameters and sum it up. I have a assembly which contains parts and sub assemblies. Some od them have parameter "wool". I would like to sum it up and place numeric value to parameter "sum_wool" in main assembly. 

 

Any ideas? Some ilogic?

4 REPLIES 4
Message 2 of 5
Xun.Zhang
in reply to: pbartosinski

Xun.Zhang
Alumni
Alumni

Hello @pbartosinski,

iLogic code can help without doubt, but if there are not many components with that parameter, then, you can directly Link the component parameter to the top assembly directly as a reference one. After that, just make a new wood_sum to sum up the total value.

Go to top assembly and click Fx, link button and select the component and find the parameter to link.

Hope it helps a little bit.


Xun
0 Likes

Hello @pbartosinski,

iLogic code can help without doubt, but if there are not many components with that parameter, then, you can directly Link the component parameter to the top assembly directly as a reference one. After that, just make a new wood_sum to sum up the total value.

Go to top assembly and click Fx, link button and select the component and find the parameter to link.

Hope it helps a little bit.


Xun
Message 3 of 5
gcoombridge
in reply to: pbartosinski

gcoombridge
Advisor
Advisor

If only the parts will have the 'wool' parameter and not the sub-assemblies use this. It will return all parts inside sub-assemblies, just not the sub-assembly itself.

Dim oDoc As AssemblyDocument
oDoc = ThisDoc.Document
Dim oOcc As ComponentOccurrence

'parameter called sum_wool already created in parameter box
sum_wool = 0

For Each oOcc In oDoc.ComponentDefinition.Occurrences.AllLeafOccurrences
	Try
		sum_wool = sum_wool +  Parameter(oOcc.Name, "wool")
	Catch
		'Do Nothing
	End Try
Next oOcc
Use iLogic Copy? Please consider voting for this long overdue idea (not mine):https://forums.autodesk.com/t5/inventor-ideas/string-replace-for-ilogic-design-copy/idi-p/3821399
0 Likes

If only the parts will have the 'wool' parameter and not the sub-assemblies use this. It will return all parts inside sub-assemblies, just not the sub-assembly itself.

Dim oDoc As AssemblyDocument
oDoc = ThisDoc.Document
Dim oOcc As ComponentOccurrence

'parameter called sum_wool already created in parameter box
sum_wool = 0

For Each oOcc In oDoc.ComponentDefinition.Occurrences.AllLeafOccurrences
	Try
		sum_wool = sum_wool +  Parameter(oOcc.Name, "wool")
	Catch
		'Do Nothing
	End Try
Next oOcc
Use iLogic Copy? Please consider voting for this long overdue idea (not mine):https://forums.autodesk.com/t5/inventor-ideas/string-replace-for-ilogic-design-copy/idi-p/3821399
Message 4 of 5
gcoombridge
in reply to: pbartosinski

gcoombridge
Advisor
Advisor
Accepted solution

This one if the sub-assembly might have the parameter. Both codes are just adjusted from this blog post: https://modthemachine.typepad.com/my_weblog/2009/03/accessing-assembly-components.html which covers the subject really well

Sub Main SumWoolSub() 
	sum_wool =0
     Dim oAsmDoc As AssemblyDocument 
    oAsmDoc = ThisApplication.ActiveDocument 

    SumWoolSub(oAsmDoc.ComponentDefinition.Occurrences, 1) 
End Sub 

Private Sub SumWoolSub(Occurrences As ComponentOccurrences, _ 
                             Level As Integer) 
    Dim oOcc As ComponentOccurrence 
    For Each oOcc In Occurrences 

	Try
		sum_wool = sum_wool +  Parameter(oOcc.Name, "wool")
	Catch
		'Do Nothing
	End Try

        If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then 
            SumWoolSub(oOcc.SubOccurrences, Level + 1) 
        End If 
    Next 
End Sub
Use iLogic Copy? Please consider voting for this long overdue idea (not mine):https://forums.autodesk.com/t5/inventor-ideas/string-replace-for-ilogic-design-copy/idi-p/3821399
0 Likes

This one if the sub-assembly might have the parameter. Both codes are just adjusted from this blog post: https://modthemachine.typepad.com/my_weblog/2009/03/accessing-assembly-components.html which covers the subject really well

Sub Main SumWoolSub() 
	sum_wool =0
     Dim oAsmDoc As AssemblyDocument 
    oAsmDoc = ThisApplication.ActiveDocument 

    SumWoolSub(oAsmDoc.ComponentDefinition.Occurrences, 1) 
End Sub 

Private Sub SumWoolSub(Occurrences As ComponentOccurrences, _ 
                             Level As Integer) 
    Dim oOcc As ComponentOccurrence 
    For Each oOcc In Occurrences 

	Try
		sum_wool = sum_wool +  Parameter(oOcc.Name, "wool")
	Catch
		'Do Nothing
	End Try

        If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then 
            SumWoolSub(oOcc.SubOccurrences, Level + 1) 
        End If 
    Next 
End Sub
Use iLogic Copy? Please consider voting for this long overdue idea (not mine):https://forums.autodesk.com/t5/inventor-ideas/string-replace-for-ilogic-design-copy/idi-p/3821399
Message 5 of 5
pbartosinski
in reply to: gcoombridge

pbartosinski
Enthusiast
Enthusiast

Works perfectly. Thank you!

Works perfectly. Thank you!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report