<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Adding constraint via API changes user constraint-setting-default in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11869455#M150925</link>
    <description>&lt;P&gt;While ideally I would prevent this from happening in the first place, I would also accept a workaround of just saving the setting before I do work, then restoring it at the end.&lt;BR /&gt;&lt;BR /&gt;However, I can't find that this user-setting is in the API anywhere that's exposed for use.&amp;nbsp; Any tips on that?&amp;nbsp; Maybe it's not exposed, but maybe I just haven't searched the right term.&lt;/P&gt;</description>
    <pubDate>Mon, 03 Apr 2023 21:08:24 GMT</pubDate>
    <dc:creator>josh.nieman</dc:creator>
    <dc:date>2023-04-03T21:08:24Z</dc:date>
    <item>
      <title>Adding constraint via API changes user constraint-setting-default</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11869441#M150924</link>
      <description>&lt;P&gt;I've combed through the code in my application to figure out why/how this is happening but to no avail.&amp;nbsp; Does anyone have any clues or ideas of where to look?&lt;BR /&gt;&lt;BR /&gt;Here's the issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Before running the code, user has "Default to undirected" &lt;STRONG&gt;checked&lt;/STRONG&gt; as below.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="joshnieman_0-1680555669588.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1197480iAB34D46AD877411E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="joshnieman_0-1680555669588.png" alt="joshnieman_0-1680555669588.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;After running a simple application function of mine that adds a fastener automatically, and constrains it appropriately, this box is unchecked.&lt;BR /&gt;&lt;BR /&gt;This is the /only/ methods that call any function related to constraints:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;HoleConst1 = AsmDef.Constraints.AddMateConstraint2(Z, ScrewHole1, "0",                                                               InferredTypeEnum.kInferredLine,                                                               InferredTypeEnum.kInferredLine,                                                               MateConstraintSolutionTypeEnum.kUndirectedSolutionType)
            FaceConst2 = AsmDef.Constraints.AddFlushConstraint(XY, FastenFace1, MateOffset)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Once complete, the next time the user opens the Constraint dialog to manually constrain something, the hole-to-hole "default to undirected" is &lt;STRONG&gt;&lt;U&gt;un&lt;/U&gt;checked&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 21:04:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11869441#M150924</guid>
      <dc:creator>josh.nieman</dc:creator>
      <dc:date>2023-04-03T21:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: Adding constraint via API changes user constraint-setting-default</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11869455#M150925</link>
      <description>&lt;P&gt;While ideally I would prevent this from happening in the first place, I would also accept a workaround of just saving the setting before I do work, then restoring it at the end.&lt;BR /&gt;&lt;BR /&gt;However, I can't find that this user-setting is in the API anywhere that's exposed for use.&amp;nbsp; Any tips on that?&amp;nbsp; Maybe it's not exposed, but maybe I just haven't searched the right term.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 21:08:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11869455#M150925</guid>
      <dc:creator>josh.nieman</dc:creator>
      <dc:date>2023-04-03T21:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Adding constraint via API changes user constraint-setting-default</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11869501#M150926</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4998597"&gt;@josh.nieman&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Per help documentation, the default SolutionType for the method&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-F770D431-7199-4646-B65C-D162DC1AAFDF" target="_blank" rel="noopener"&gt;AddMateConstraint2&lt;/A&gt; is "kOpposedSolutionType".&amp;nbsp; Maybe it is changing the default when you call the method without specifying a&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-88C5CA01-BC92-44BB-8E21-246CFD7B010E" target="_blank" rel="noopener"&gt;SolutionType&lt;/A&gt; when you make the constraint.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 21:24:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11869501#M150926</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2023-04-03T21:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Adding constraint via API changes user constraint-setting-default</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11870985#M150937</link>
      <description>&lt;P&gt;The formatting botched my code snippet, but I am specifying a solutiontype of "undirected"&lt;BR /&gt;&lt;BR /&gt;However, if that is changing the default, I consider that a bug.&lt;BR /&gt;&lt;BR /&gt;Specifying an optional parameters on an 'addConstraint' function shouldn't change a user-set default value.&amp;nbsp; That is the very reason 'defaults' exist.&amp;nbsp; So it would default to a thing unless otherwise stated: implying that it's ok to state otherwise without changing things.&lt;BR /&gt;&lt;BR /&gt;Can anyone else replicate the behavior (trying a second code snip that better shows my code)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;    &amp;lt;Extension()&amp;gt;
    Public Function ConstrainIt(TheScrew As ComponentOccurrence, Optional WasherBool As Boolean = False, Optional TheWasher As ComponentOccurrence = Nothing) As Boolean
        Dim ScrewDef As PartComponentDefinition = TheScrew.Definition
        Dim WashDef As PartComponentDefinition = Nothing
        If WasherBool Then
            Debug.Print("constrain0")
            WashDef = TheWasher.Definition
        End If

        Debug.Print("constrain1")
        Dim MateOffset As String = "0"

        Dim XY As WorkPlaneProxy = Nothing
        TheScrew.CreateGeometryProxy(ScrewDef.WorkPlanes.Item(3), XY)
        Dim Z As WorkAxisProxy = Nothing
        TheScrew.CreateGeometryProxy(ScrewDef.WorkAxes.Item(3), Z)

        If ScrewType = "FHCS" Then
            'offset by some factor (or get the parameter from the part) so we're flush
            MateOffset = 1
        ElseIf ScrewType = "SHCS" OrElse
                ScrewType = "HHCS" OrElse
                ScrewType = "BHCS" OrElse
                ScrewType = "LHCS" Then
            If WasherBool Then
                Debug.Print(WasherUsed.Thickness &amp;amp; " washer thickness")
                MateOffset = "-" &amp;amp; WasherUsed.Thickness ' negative value
                Debug.Print("Mate Offset = " &amp;amp; MateOffset)
            End If
            HoleConst1 = AsmDef.Constraints.AddMateConstraint2(Z, ScrewHole1, "0",
                                                               InferredTypeEnum.kInferredLine,
                                                               InferredTypeEnum.kInferredLine,
                                                               MateConstraintSolutionTypeEnum.kUndirectedSolutionType)
            FaceConst2 = AsmDef.Constraints.AddFlushConstraint(XY, FastenFace1, MateOffset)
            If WasherBool AndAlso WashDef IsNot Nothing Then
                Dim washXY As WorkPlaneProxy = Nothing
                TheWasher.CreateGeometryProxy(WashDef.WorkPlanes.Item(3), washXY)
                Dim washZ As WorkAxisProxy = Nothing
                TheWasher.CreateGeometryProxy(WashDef.WorkAxes.Item(3), washZ)
                HoleConstW1 = AsmDef.Constraints.AddMateConstraint2(washZ, ScrewHole1, "0",
                                                                    InferredTypeEnum.kInferredLine,
                                                                    InferredTypeEnum.kInferredLine,
                                                                    MateConstraintSolutionTypeEnum.kUndirectedSolutionType)
                FaceConstW2 = AsmDef.Constraints.AddFlushConstraint(washXY, FastenFace1, WasherUsed.Thickness * 2.54 / 2 * -1) 'half washer thickness, inch to cm, and negative
            End If
        Else
            ' not FHCS/SHCS/HHCS/BHCS/LHCS so maybe they hit escape to cancel or something
            Return False
        End If
        Return True
    End Function&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 10:10:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11870985#M150937</guid>
      <dc:creator>josh.nieman</dc:creator>
      <dc:date>2023-04-04T10:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Adding constraint via API changes user constraint-setting-default</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11870991#M150938</link>
      <description>&lt;P&gt;I cannot find anything that seems like it should be changing a default setting.&lt;BR /&gt;&lt;BR /&gt;By calling "AddMate/FlushConstraint" I don't feel like it should be changing any /default/ setting.&amp;nbsp; If it does, though, I'd certainly want to "put it back" to whatever it was before my code caused the change, and I cannot find a way I can do that.&amp;nbsp; Does anyone know of a way?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 10:12:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11870991#M150938</guid>
      <dc:creator>josh.nieman</dc:creator>
      <dc:date>2023-04-04T10:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Adding constraint via API changes user constraint-setting-default</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11886214#M151163</link>
      <description>&lt;P&gt;Bump?&lt;BR /&gt;&lt;BR /&gt;No ideas?&amp;nbsp; &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@F462EEC827775DA92CB03B7FC147D389/emoticons/1f61e.png" alt=":disappointed_face:" title=":disappointed_face:" /&gt;&amp;nbsp; This is a bummer.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 22:01:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11886214#M151163</guid>
      <dc:creator>josh.nieman</dc:creator>
      <dc:date>2023-04-10T22:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Adding constraint via API changes user constraint-setting-default</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11896105#M151356</link>
      <description>&lt;P&gt;Well I updated a bit of completely unrelated code, and re-built the DLL and noticed the problematic behavior has stopped so far.&lt;BR /&gt;&lt;BR /&gt;Ghosts in the machine, gremlins in the code... I don't even know, but I'm moving on unless this crops up again &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@F982DDE76110C67DBDB6AF220B48480A/emoticons/1f604.png" alt=":grinning_face_with_smiling_eyes:" title=":grinning_face_with_smiling_eyes:" /&gt;&lt;BR /&gt;&lt;BR /&gt;Apologies to anyone who comes across this thread in the future, who might be searching for resolution to similar troubles.&amp;nbsp; Good luck.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 11:49:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-constraint-via-api-changes-user-constraint-setting/m-p/11896105#M151356</guid>
      <dc:creator>josh.nieman</dc:creator>
      <dc:date>2023-04-14T11:49:58Z</dc:date>
    </item>
  </channel>
</rss>

