iLogic dynamic Parameter update off?

iLogic dynamic Parameter update off?

PaulMunford
Community Manager Community Manager
2,703 Views
7 Replies
Message 1 of 8

iLogic dynamic Parameter update off?

PaulMunford
Community Manager
Community Manager

Can anyone help me with this rule?

 

The rule iterates through an assembly looking for parameters. If it finds them it 'pushes' the value down from the top level Assembly into the sub-components.

 

It works well, but each component updates dynamically as the parameter value is changed. This looks a bit jerky and weird.

 

Is there any way to write the script so the the updates all happen at once at the end?

 

Thanks in advance for any help you can give,

 

Paul

 

' set a reference to the assembly component definintion.
' This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences

'check for and skip virtual components
'(in case a virtual component trips things up)
If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then
Parameter.Quiet = True

'Match up the cabinet height
If Parameter(oOccurrence.Name, "Cheight") Then
Parameter(oOccurrence.Name, "Cheight") = Cheight
End If

'Match up the cabinet width
If Parameter(oOccurrence.Name, "Cwidth") Then
Parameter(oOccurrence.Name, "Cwidth") = Cwidth
End If

'match up the cabinet depth
If Parameter(oOccurrence.Name, "Cdepth") Then
Parameter(oOccurrence.Name, "Cdepth") = Cdepth
End If

'Match up the Left panel thickness
If Parameter(oOccurrence.Name, "CLthick") Then
Parameter(oOccurrence.Name, "CLthick") = CLthick
End If

'Match up the right panel thickness
If Parameter(oOccurrence.Name, "CRthick") Then
Parameter(oOccurrence.Name, "CRthick") = CRthick
End If

'Match up the top panel thickness
If Parameter(oOccurrence.Name, "CTthick") Then
Parameter(oOccurrence.Name, "CTthick") = CTthick
End If

'Match up the base panel thickness
If Parameter(oOccurrence.Name, "CBthick") Then
Parameter(oOccurrence.Name, "CBthick") = CBthick
End If

'Match up the back  panel thickness
If Parameter(oOccurrence.Name, "CBKthick") Then
Parameter(oOccurrence.Name, "CBKthick") = CBKthick
End If

'Uodate the document to see the changes
InventorVb.DocumentUpdate()

Else
End If
Next

 

P.S.

Kudos to Curtis Waguespack for the code that got me started!

http://inventortrenches.blogspot.co.uk/2012/08/ilogic-virtual-components.html


Customer Adoption Specialist: Autodesk Informed Design
Help | Learn | Forum | Blog | Ideas | Sample content | Linkedin 

0 Likes
2,704 Views
7 Replies
Replies (7)
Message 2 of 8

Vladimir.Ananyev
Alumni
Alumni

What if you put command

'Uodate the document to see the changes
InventorVb.DocumentUpdate()

after the Next statement ?

Now the rule updates the assembly document in every for - next loop.

 

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 8

PaulMunford
Community Manager
Community Manager

Thanks Vladimir!

 

That helped a bit - but there is still one update for each componet that contains a parameter that needs updating - so it's still a bit jerky...

 

Any other suggestions?

 

Paul


Customer Adoption Specialist: Autodesk Informed Design
Help | Learn | Forum | Blog | Ideas | Sample content | Linkedin 

0 Likes
Message 4 of 8

AlexFielder
Advisor
Advisor

What about the .DeferUpdate() option:

 

deferupdates.PNG

if you put the .DeferUpdate() at the beginning of the code and then have Inventor.AssemblyDocument.Update() (or whatever you called your Assembly Object) at the very end it would likely do all the parameter changes and then update?

Message 5 of 8

PaulMunford
Community Manager
Community Manager

Thanks for the suggestion Alex - no luck I'm afraid.

 

I think that the -

Parameter("Part1:1", "d0") = 1.2

- method, updates the documents dynamically, as the program is running...

 

I thin kI need to find another meathod to change the parameter values...


Customer Adoption Specialist: Autodesk Informed Design
Help | Learn | Forum | Blog | Ideas | Sample content | Linkedin 

0 Likes
Message 6 of 8

AlexFielder
Advisor
Advisor

What about this page from Curtis Wagespack:

 

http://inventortrenches.blogspot.co.uk/2011/02/autodesk-ilogic-highlight-and-update.html

 

I have to wonder what would happen if you put the following after each of the parameter changes:

Parameter("Part1:1", "d0") = 1.2
'add these lines:
RuleParametersOutput()
iLogicVb.UpdateWhenDone True

 ? (It might also be worth experimenting with the UpdateWhenDone boolean to see if changing it to false stops the auto-update you're currently seeing.)

 

0 Likes
Message 7 of 8

Vladimir.Ananyev
Alumni
Alumni

You may consider the access to the document’s parameters collection via direct calls through Inventor API.  In this case you may change all required parameters and only then execute one update operation for this particular document.  
Here is code demo:

Sub Main()
	'assume this is assembly document
	Dim oAsmDef As AssemblyComponentDefinition _
		= ThisDoc.Document.ComponentDefinition
	
	'Iterate through all of the occurrences
	Dim oOcc As ComponentOccurrence
	For Each oOcc In oAsmDef.Occurrences
		'ignore substitutes
		If oOcc.IsSubstituteOccurrence Then Continue For
		'ignore virtual component
		If TypeOf oocc.definition Is VirtualComponentDefinition Then Continue For	

		Dim oPars as Inventor.Parameters = oOcc.Definition.Parameters
		
		'set value for parameter  AAA (value is hard coded = 33.3 cm)
		If Not SetParameterValue(oPars, "AAA", 33.3) Then
'error message if needed MsgBox("Component: " & oocc.Name & vbNewLine & _ "Parameter not found: " & ParName ) End If ' ... 'set value for parameter BBB ' ... 'set value for parameter CCC ' ... 'set value for parameter DDD ' ... and so on
'document update individually if needed 'oOcc.Definition.Document.Update Next 'update assembly document InventorVb.DocumentUpdate() Beep MsgBox("Completed.") End Sub ' Main
' low-level aux. function Private Function SetParameterValue( _ ByVal oPars as Inventor.Parameters, _ ByVal ParName As String, _ ByVal ParValue As Double) As Boolean Try oPars.Item(ParName).Value = ParValue
' you may also use Expression property to set the value by string (e.g. "33 mm") Return True Catch Return False 'error message End Try End Function

Please let us know which method is faster in your case and what is the difference (in %)?

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 8 of 8

PaulMunford
Community Manager
Community Manager

Thanks for the code Vladimir.

 

It works well (I used the 'Expression' method of changing the parameter values - I am inputing measurements in mm)

 

However - it doesn't solve the problem.

 

But I think that I understand what I've done - 

 

The top level assembly is pushing values to the sub assemblies.

The sub assemblies are using iLogic to push values down to the parts.

The parts update dynamically.

 

I think that I'm seeing a 'Trickle down' effect of having nested iLogic routines running. This is what is causing the 'Jerky effect'. As such - I don't think that it is solvable 😞

 

Thanks for your help though!

 

Until next time.

 

Paul


Customer Adoption Specialist: Autodesk Informed Design
Help | Learn | Forum | Blog | Ideas | Sample content | Linkedin 

0 Likes