- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@JBerns wrote:
Thanks for the quick reply.
I noticed your line of code with the offset has more parameters as compared to mine.
I think the difference you're noticing is due to the use of the API function "AddFlushConstraint" vs the iLogic function "AddFlush", that do pretty much the same thing.
The iLogic function is what you get when you use Capture Current State.
Inventor API function to create a flush constraint
oAsmCompDef.Constraints.AddFlushConstraint(oAsmCompDef.WorkPlanes("XY Plane"), oproxyPlaneAFLXY, Offset:=offsetExpression)
iLogic function to create a flush constraint
Constraints.AddFlush("Flush:2", "PT_300:1", "Face2", "PT_100:1", "Face3")
The iLogic function will accept a string as the offset value and use it as an expression, without the need to do anything else. The API function requires an extra step as Michael.Navara's example shows.
But it might help to understand the difference, by understanding how to work with both functions and their resulting objects, together.
To do that we could do something like the example below where we add the constraint using the iLogic function, but capture it with a variable, for use later.
It is created as an iLogic IManagedConstraint object. As can be seen in the tooltip by hovering over the ilogic AddFlush function.
This allows you to add the constraint and then access it again later to set the offset.
I might use something like this if I were adding components to an assembly, constraining them in place, and then using some calculation or condition later in the rule to change the location of one of them.
To do that we just need to sort of take the mask off of the iManagedConstraint object to find the underlaying API constraint object, so that we can do API stuff
You might recall this image from Autodesk University.
The short version is that we can get the underlaying API object from pretty much any iLogic object.
Dim PT_100_1 = Components.Add("PT_100:1", "PT_100.ipt", grounded := True) Dim PT_300_1 = Components.Add("PT_300:1", "PT_300.ipt") Constraints.AddMate("Mate:1", "PT_100:1", "Face1", "PT_300:1", "Face0") Constraints.AddFlush("Flush:1", "PT_300:1", "Face1", "PT_100:1", "Face2") MyiLogicFlush = Constraints.AddFlush("Flush:2", "PT_300:1", "Face2", "PT_100:1", "Face3") 'some other code here, to do stuff, with things 'some other code here, to do stuff, with things 'some other code here, to do stuff, with things
'get the API constraint object from the iLogic constraint object Dim oFlush As FlushConstraint = MyiLogicFlush.Constraint
'define the offset expression Dim offsetExpression As String = "Return_Rail_Liner_Thickness * -1.0 ul"
'set the expression oFlush.Offset.Expression = offsetExpression