<?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: How to add curves from a ProfilesCurves collection to an ObjectCollection? C in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-add-curves-from-a-profilescurves-collection-to-an/m-p/6409566#M19649</link>
    <description>&lt;P&gt;Hi Brian,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Awesome explanation, don't think I would have figured that out alone:-) My code is back in action.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Rod.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jun 2016 23:41:37 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-06-28T23:41:37Z</dc:date>
    <item>
      <title>How to add curves from a ProfilesCurves collection to an ObjectCollection? C++</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-add-curves-from-a-profilescurves-collection-to-an/m-p/6409507#M19647</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to add curves from an outer ProfileLoop to an ObjectCollection for later offset. The following code is crashing however. Any pointers (no pun intended) as to what's going on?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rod.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;Ptr&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;Profiles&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt; profiles = sketchIn-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;profiles&lt;/SPAN&gt;&lt;SPAN&gt;();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;Ptr&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;ObjectCollection&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt; curvesForOffset = &lt;/SPAN&gt;&lt;SPAN&gt;ObjectCollection&lt;/SPAN&gt;&lt;SPAN&gt;::&lt;/SPAN&gt;&lt;SPAN&gt;create&lt;/SPAN&gt;&lt;SPAN&gt;();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;for&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;Ptr&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;Profile&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt; profile : profiles)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;Ptr&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;ProfileLoops&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt; loops = profile-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;profileLoops&lt;/SPAN&gt;&lt;SPAN&gt;();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;for&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;Ptr&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;ProfileLoop&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt; loop : loops)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;Ptr&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;ProfileCurves&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt; loopCurves = loop-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;profileCurves&lt;/SPAN&gt;&lt;SPAN&gt;();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (loop-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;isOuter&lt;/SPAN&gt;&lt;SPAN&gt;())&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; curvesForOffsetOut = sketchIn-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;findConnectedCurves&lt;/SPAN&gt;&lt;SPAN&gt;(loopCurves-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;item&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 22:46:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-add-curves-from-a-profilescurves-collection-to-an/m-p/6409507#M19647</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-28T22:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to add curves from a ProfilesCurves collection to an ObjectCollection? C</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-add-curves-from-a-profilescurves-collection-to-an/m-p/6409540#M19648</link>
      <description>&lt;P&gt;You're mixing two different things here that can't be mixed.&amp;nbsp; Although it's completely understandable how you would make that mistake.&amp;nbsp; In the picture below I've drawn three lines in a sketch.&amp;nbsp; Only in one of the corners do the line lines geometrically connect at their ends.&amp;nbsp; At one of the other two corners they overlap and at the other one butts up to the other.&amp;nbsp; The triangular profile is also shown.&amp;nbsp; If I was to get the Profile loop for this profile it would consist of three ProfileCurve objects and they are represented in the picture below by the black lines.&amp;nbsp; These curves don't really exist in the sketch but are just the results of the profile being calculated and are only part of the profile.&amp;nbsp; I can't offset profile curves.&amp;nbsp; You can only offset sketch curves.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG title="Profile.png" alt="Profile.png" src="https://forums.autodesk.com/t5/image/serverpage/image-id/251247i7690A6881F0778C8/image-size/original?v=v2&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you know you have clean sketches where the sketch curves connect end-to-end then they will match the profile curves.&amp;nbsp; In the Python code below, (it was quicker to write and test&amp;nbsp;than C++),&amp;nbsp;I do what you described by getting the outer profile loop and iterating over its curves, but for each ProfileCurve I get the associated sketch entity and add that to the collection and then that's what is offset.&amp;nbsp; Hopefully that makes some sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;def run(context):
    try:
        des = adsk.fusion.Design.cast(app.activeProduct)
        sketchIn = adsk.fusion.Sketch.cast(des.activeEditObject)
        profiles = sketchIn.profiles
        
        curvesForOffset = adsk.core.ObjectCollection.create()

        profile = adsk.fusion.Profile.cast(None)
        for profile in profiles:
            loops = profile.profileLoops            
            
            if loops.count &amp;gt; 1:            
                loop = adsk.fusion.ProfileLoop.cast(None)
                for loop in loops:
                    if loop.isOuter:
                        curve = adsk.fusion.ProfileCurve.cast(None)
                        for curve in loop.profileCurves:
                            curvesForOffset.add(curve.sketchEntity)

        if curvesForOffset.count &amp;gt; 0:
            sketchIn.offset(curvesForOffset, adsk.core.Point3D.create(0,0,0), 1)                        
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jun 2016 23:15:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-add-curves-from-a-profilescurves-collection-to-an/m-p/6409540#M19648</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2016-06-28T23:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to add curves from a ProfilesCurves collection to an ObjectCollection? C</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-add-curves-from-a-profilescurves-collection-to-an/m-p/6409566#M19649</link>
      <description>&lt;P&gt;Hi Brian,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Awesome explanation, don't think I would have figured that out alone:-) My code is back in action.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Rod.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 23:41:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-add-curves-from-a-profilescurves-collection-to-an/m-p/6409566#M19649</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-28T23:41:37Z</dc:date>
    </item>
  </channel>
</rss>

