constraints in ilogic

Anonymous

constraints in ilogic

Anonymous
Not applicable
I have a component that has to be at a certain place if the length of the overall assembly is a certain size and has to be at a different place if the assembly it's going into is a different size. Is there a way to have this constraint change using iLogic or do I need to make another component and just have them turn on and off between themselves? I do not just have two different positions, I have more than 100 different positions. I'm thinking the best way to do this would be to create the constraint and then immediately delete it so its ready for the next movement.
0 Likes
Reply
2,877 Views
15 Replies
Replies (15)

MechMachineMan
Advisor
Advisor
Just create 2 constraints; 1 for either position and always have 1 suppressed and the other active. Easiest way to do it. Then use an iLogic rule to check a parameter, and change the suppression of the constraints based upon the result.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type

cwhetten
Advisor
Advisor

I certainly wouldn't leave the part unconstrained (i.e. deleting the constraint)--that's just asking for problems.  There are a number of ways this could be done:

 

-   Create parameters for the constraint offsets, then use iLogic to control the parameter values for each configuration.

 

-   Use iLogic to edit the constraints--change their offset expressions / formulas, change their references, etc.

 

-   Set up a set of constraints for each configuration and use iLogic to suppress & unsuppress constraints (Edit: what MechMachineMan said)

 

-   Create positional representations for each config, use iLogic to set the positional rep.

 

-   Create workplanes / axes / points in your parts and subassemblies, constrain to this work geometry

 

-   Other less-savory methods like you mentioned...  Smiley Wink

 

Cameron Whetten
Inventor 2014

Anonymous
Not applicable
That would work fine if I had two positions but I said that I have more than 100. I found that answer on another thread but my question is different. I have many positions which is I am having difficulty with.
0 Likes

Anonymous
Not applicable
I am attaching a bumper to the end of a car. If the length of the assembly of cars is 10 cars then I want the bumper to attach to the end of the 10th car. If the assembly is 120 cars I want the bumper to attach to the end of the 120th car. Am I able to do that with your methods? I am not sure which one is best to use for this situation...
0 Likes

cwhetten
Advisor
Advisor

Are all of the cars the same length?  If so, then a simple parameter formula should do the trick--no iLogic necessary.

 

Cameron Whetten
Inventor 2014

0 Likes

Anonymous
Not applicable
They are the same length but the train of cars may make two turns...Its not straight.
0 Likes

cwhetten
Advisor
Advisor

You say it "may make two turns".  Does that mean that the number of turns can vary?  As in, it could be either 0, 1, or 2 turns?

 

If so, then we're back to iLogic, but I'm still thinking parameter formulas will work.  But, instead of a single formula, iLogic will choose between 3 or so formulas.

 

Can you provide any more specific information?  I might be able to work up an example, but each time you post, you give new information Smiley Happy...  So, if I did an example now, it might not be useful to you if I am missing more of the puzzle.

 

Do you have any example files or screenshots you can provide?  How about a list of the different variables?

 

Cameron Whetten
Inventor 2014

0 Likes

Anonymous
Not applicable
I attached a picture of a street setting. The angled squares are city blocks. Theres many different combinations of turns that the line of cars could take.
0 Likes

cwhetten
Advisor
Advisor

I don't see any attachments.  Sometimes they don't work correctly.  Try it again, or just insert the image into your message, like this:

 

Insert Image.PNG

Cameron Whetten
Inventor 2014

0 Likes

Anonymous
Not applicable

Foud it! I attached it in the post. getting to second street.png

0 Likes

cwhetten
Advisor
Advisor

I have attached a simplified example of how I might do it (based on the information you have given so far).  This is using iLogic to turn off and on patterns of components (the trains of cars), and to turn off and on constraints.

 

The bumper part is constrained to each of 5 workpoints.  The workpoints are created from a curve-driven pattern in the Path Sketches.ipt part file.  The curve pattern keeps the workpoints always at the end of the train of cars, regardless of changes to the CarLength, CarSpacing, xLength, zLength, or ArcRadius parameters.

 

The patterns of cars are feature-driven component patterns.  The feature patterns they are driven by are in the Path Sketches.ipt part file, and these feature patterns are also curve-driven, similar to the way the workpoints are created.

 

The attached files are version 2014.

 

Out of curiosity, what are you designing?

 

Cameron Whetten
Inventor 2014

Anonymous
Not applicable

Thank you for sharing this with me!!

 

It's actually a project for work so I can't exactly say what it is.

 

I already created the line of cars which use parameters generated in excel using VBA. When I open up your file and look at how the bumper is constrained I see that train1-train5 show the same work point for all. Will this method work if I constrained the cars a different way and the number of cars varies? I posted a comments ago that number of cars vary. I have a line of around 500 cars and I wrote some ilogic that would turn off the visibility of the cars I dont need. So I have a line of 300 cars then the program turns off 200 cars.

 

0 Likes

cwhetten
Advisor
Advisor

Without seeing exactly how your design is set up, all I can do is make guesses and show simplified examples.

 

In the assembly I posted, the number of cars changes based on the parameters xLength, zLength, CarLength, and CarSpacing.  It adjusts the number of cars to be evenly spaced along the given path.  So, the bumper part automatically adjusts to the number of cars.

 

If your parameters are set up differently, the general concept should still work: the parameter formulas control the workpoint locations for each path, and the iLogic controls which workpoint the bumper is constrained to.

 

I should have mentioned in my previous post that if you open the assembly parameters, you can change the value of the Configuration parameter to see the line of cars change path, and the bumper follows to always attach to the last car.

 

Cameron Whetten
Inventor 2014

Anonymous
Not applicable

I'm sorry I can't give you more information...

 

'Code that places the bumper 
Sub Main()

    Dim oAsmCompDef As AssemblyComponentDefinition
    oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition


    ' Get references to the two occurrences to constrain.
    ' This arbitrarily gets the first and second occurrence.
    Dim oOcc1 As ComponentOccurrence
    oOcc1 = oAsmCompDef.Occurrences.Item(Car)

    Dim oOcc2 As ComponentOccurrence
    oOcc2 = oAsmCompDef.Occurrences.Item(Bumper)


    Dim oPartPoint1 As WorkPoint
     oPartPoint1 = oOcc1.Definition.WorkPoints.Item(1)

    Dim oPartPoint2 As WorkPoint
    oPartPoint2 = oOcc2.Definition.WorkPoints.Item(1)

    Dim oPartPlaneXY As WorkPlane
    oPartPlaneXY = oOcc1.Definition.WorkPlanes(3)
    
    Dim oPart2PlaneXY As WorkPlane
    oPart2PlaneXY = oOcc2.Definition.WorkPlanes(3)

    
    Dim oAsmPoint1 As WorkPointProxy
    Call oOcc1.CreateGeometryProxy(oPartPoint1, oAsmPoint1)

    Dim oAsmPoint2 As WorkPointProxy
    Call oOcc2.CreateGeometryProxy(oPartPoint2, oAsmPoint2)
    
    Dim oPartPlane1 As WorkPlaneProxy 
    Call oOcc1.CreateGeometryProxy(oPartPlaneXY, oPartPlane1)
    
    Dim oPart2Plane1 As WorkPlaneProxy
    Call oOcc2.CreateGeometryProxy(oPart2PlaneXY, oPart2Plane1)

    
    ' Create the constraint using the work point proxies.
    Call oAsmCompDef.Constraints.AddMateConstraint(oAsmPoint1, oAsmPoint2, 0)
    Call oAsmCompDef.Constraints.AddMateConstraint(oPartPlane1, oPart2Plane1, 0)
 
End Sub

 

 

This is the code that I am using currently to place the bumper. It creates a new constraint every time the code is ran. I dont know how to just change what it's constrained to rather than creating a brand new one.

0 Likes

Anonymous
Not applicable

Maybe I could possibly create another iLogic rule to delete the previously created constraint then add it to the iTrigger so when I run the iTrigger it will first delete the previously made constraint then create the new one. The bumper will always be constrained to a car. Think it will work? I’m currently searching for the logic to programmatically delete a constraint. The constraints always have the same label.

0 Likes