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: 

Rules

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
ASchlaack
254 Views, 5 Replies

Rules

I need a rule to have it auto update/ rerun all constraits, is there a rule that can be written for that? If so what is it?

Thanks,

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
5 REPLIES 5
Message 2 of 6
jalger
in reply to: ASchlaack

Hi Aschlaack,

 

Here is the code:

 

Constraint.IsActive("Name of Mate") = True : To turn the Mate On

Constraint.IsActive("Name of Mate") = False : To turn the Mate Off

 

You might be able to loop the Routine to turn on all mates if they all have Similar Stabilized names.

(example: Mate_1, Mate_2, Mate_3, etc don't leave them the way they are if you reuse the assembly it will regenerate the Mates and they will no longer be correct in the code that why we stabilize them)

 

I don't have any code for looping... so hopefully someone sees this post and can help you out further.

 

I hope this helps,

 

James

James Alger
(I'm on several hundred posts as "algerj")

Work:
Dell Precision 5530 (Xeon E 2176M)
1tb SSD, 64GB RAM
Nvidia Quadro P2000, Win10
Message 3 of 6
ASchlaack
in reply to: jalger

Thanks James but that's not quite what I needed..

 

To be a little more exact about what I need:

I have over 500 constraits so I more of need a way to just have them all be updated at once. I'm doing a lot with iRules and iParts/iAssembolies and when I change them too drastically it doesn't always want to have all the constrants be correct anymore. Normally how I go about fixing them is to set it to a different iAssemboly value and that causes everything to reload and that constrant suddenly kicks in and works correctly.

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
Message 4 of 6

Hi ASchlaack,

Building on what jalger suggested, here is a rule that will toggle the suppression of each assembly component in the assembly. Note that the rule currently sets the Master level of detail active before looking at the constraints, but that might not be needed for your situaton, and could be removed.

 

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

'set the Master LOD active
Dim oLODRep As LevelofDetailRepresentation
oLODRep = oAsmCompDef.RepresentationsManager. _
LevelOfDetailRepresentations.Item("Master")
oLODRep.Activate

' Iterate through all of the constraints in this assembly twice
i = 0
Do Until i = 2
Dim oConstraint As AssemblyConstraint
    For Each oConstraint In oAsmCompDef.Constraints
    ‘toggle constrain supression
        If oConstraint.Suppressed = False Then
        oConstraint.Suppressed = True
        Else
        oConstraint.Suppressed = False
        End If
    Next
    i = i + 1
    ‘rebuild all
    InventorVb.DocumentUpdate()
    ‘ adds a small delay here
    PauseTime = 0.2 'seconds
    Start = Timer
    Do While Timer < Start + PauseTime
    ThisApplication.UserInterfaceManager.DoEvents
    'present a status bar message    
    ThisApplication.StatusBarText = "File is updating...."
    Loop
Loop
    'set status bar message    
    ThisApplication.StatusBarText = “Rule Complete!”

 

Note though that you might only need this one line. You might try it to see if will do what you're aftar.

 

‘rebuild all
InventorVb.DocumentUpdate()

 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Message 5 of 6

In my case I'm working in LevelofDetail1, what needs to be changed? And once that's changed I can just paste that into a rule and It's good to go correct?

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
Message 6 of 6


@ASchlaack wrote:

In my case I'm working in LevelofDetail1, what needs to be changed? And once that's changed I can just paste that into a rule and It's good to go correct?


 

Hi ASchlaack,

 

Here is the rule with the LOD stuff removed. It ran it real quick and it didn't seem to cause me any issues. And yes, you can just paste this in to a new iLogic rule and run it.

 

Also, not that I edited my last post to suggest a possible single line solution using: InventorVb.DocumentUpdate()

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

' 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 constraints in this assembly twice
i = 0
Do Until i = 2
Dim oConstraint As AssemblyConstraint 
    For Each oConstraint In oAsmCompDef.Constraints 
    ‘toggle constrain supression
        If oConstraint.Suppressed = False Then
        oConstraint.Suppressed = True
        Else 
        oConstraint.Suppressed = False
        End If
    Next
    i = i + 1
    ‘rebuild all
    InventorVb.DocumentUpdate()
    ‘ adds a small delay here
    PauseTime = 0.2 'seconds
    Start = Timer
    Do While Timer < Start + PauseTime
    ThisApplication.UserInterfaceManager.DoEvents
    'present a status bar message    
    ThisApplication.StatusBarText = "File is updating...."
    Loop
Loop
    'set status bar message    
    ThisApplication.StatusBarText = “Rule Complete!”

 

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

Post to forums  

Autodesk Design & Make Report