<?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: Examples of using sketch.copy in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/examples-of-using-sketch-copy/m-p/11356775#M5592</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12364171"&gt;@Jorge_Jaramillo&lt;/a&gt;That did the trick - thanks!&amp;nbsp; The following pseudocode:&lt;/P&gt;&lt;P&gt;-- Let the user select a profile&lt;/P&gt;&lt;P&gt;selFace = ui.selectEntity("Pick face to replicate", "Profiles")&lt;BR /&gt;profile = selFace.entity&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;create an empty adsk.core.ObjectCollection&lt;/P&gt;&lt;P&gt;for each loop in profile.profileLoops&lt;/P&gt;&lt;P&gt;&amp;nbsp; for each curve in loop.profileCurves&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; add the curve to the objectCollection&lt;/P&gt;&lt;P&gt;profile.parentSketch.copy(objectCollection, matrix, targetSketch)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The next level issue I've run into is that sometimes the math gets weirded out and I can't Loft across the copied profiles, but that's for a different thread.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Aug 2022 23:03:23 GMT</pubDate>
    <dc:creator>OldSchoolMakerD</dc:creator>
    <dc:date>2022-08-12T23:03:23Z</dc:date>
    <item>
      <title>Examples of using sketch.copy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/examples-of-using-sketch-copy/m-p/11339357#M5589</link>
      <description>&lt;P&gt;I'd like to understand better how one can use the sketch.copy function.&amp;nbsp; What I'm doing in my script is letting a user select a face on a sketch, and then I want to copy and paste that sketch in multiple other sketches, optionally using the Matrix3D transformation to scale it.&amp;nbsp; My code uses&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;selFace&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;ui&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;selectEntity&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"Pick face to replicate"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"Profiles"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;to let someone pick the profile.&amp;nbsp; From there, I can get the entity of selFace, which itself is of type adsk.fusion.Profile.&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the profile, I can get the sketch containing the profile.&lt;/P&gt;&lt;P&gt;Later, I'm basically calling sketch.copy using the profile's parent sketch, so it's like this:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;profile&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;parentSketch&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;copy&lt;/SPAN&gt;&lt;SPAN&gt;(**&lt;/SPAN&gt;&lt;SPAN&gt;something**&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;mat3D, otherSketch&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;The problem is that I keep getting&lt;/P&gt;&lt;P&gt;RuntimeError: 3 : invalid input in sketchEntities&lt;/P&gt;&lt;P&gt;depending on what I put in for **something**.&amp;nbsp; The API calls for an ObjectCollection there, and so I create a new ObjectCollection and add the selected profile to it.&lt;/P&gt;&lt;P&gt;I figure I'm either adding the wrong kinds of objects to the ObjectCollection, or I'm adding the wrong instances of objects to it -- because, I presume they must be entities that belong to the parentSketch in some way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's the right way to do this?&amp;nbsp; Given a sketch and a selected profile, how should I construct the ObjectCollection so that parentSketch.copy will work?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 07:05:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/examples-of-using-sketch-copy/m-p/11339357#M5589</guid>
      <dc:creator>OldSchoolMakerD</dc:creator>
      <dc:date>2022-08-04T07:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Examples of using sketch.copy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/examples-of-using-sketch-copy/m-p/11339409#M5590</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/9282716"&gt;@OldSchoolMakerD&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Sketch.copy() method expect as first parameter an object collection of sketch curves, not of profile(s).&lt;/P&gt;&lt;P&gt;Since you have the profile, you can add all profileCurves inside all profilesLoops of the profile into the object collection, and that will solve your problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this could help.&amp;nbsp; Let me know if this works for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jorge&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 07:40:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/examples-of-using-sketch-copy/m-p/11339409#M5590</guid>
      <dc:creator>Jorge_Jaramillo</dc:creator>
      <dc:date>2022-08-04T07:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: Examples of using sketch.copy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/examples-of-using-sketch-copy/m-p/11340255#M5591</link>
      <description>&lt;P&gt;Thanks!&amp;nbsp; I'll try that.&amp;nbsp; I guess reading the big API PDF doesn't make it easy for me to understand what's a child of Entity, etc., and being in Python instead of C++ isn't helping me understand that, either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, sort of answering my own question here... I ran across this post.&amp;nbsp; Of course I found the day after posting my question...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/fusion-360-api-and-scripts/how-to-duplicate-a-sketch-by-using-api/td-p/9804407" target="_blank"&gt;https://forums.autodesk.com/t5/fusion-360-api-and-scripts/how-to-duplicate-a-sketch-by-using-api/td-p/9804407&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 15:02:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/examples-of-using-sketch-copy/m-p/11340255#M5591</guid>
      <dc:creator>OldSchoolMakerD</dc:creator>
      <dc:date>2022-08-04T15:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Examples of using sketch.copy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/examples-of-using-sketch-copy/m-p/11356775#M5592</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12364171"&gt;@Jorge_Jaramillo&lt;/a&gt;That did the trick - thanks!&amp;nbsp; The following pseudocode:&lt;/P&gt;&lt;P&gt;-- Let the user select a profile&lt;/P&gt;&lt;P&gt;selFace = ui.selectEntity("Pick face to replicate", "Profiles")&lt;BR /&gt;profile = selFace.entity&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;create an empty adsk.core.ObjectCollection&lt;/P&gt;&lt;P&gt;for each loop in profile.profileLoops&lt;/P&gt;&lt;P&gt;&amp;nbsp; for each curve in loop.profileCurves&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; add the curve to the objectCollection&lt;/P&gt;&lt;P&gt;profile.parentSketch.copy(objectCollection, matrix, targetSketch)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The next level issue I've run into is that sometimes the math gets weirded out and I can't Loft across the copied profiles, but that's for a different thread.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2022 23:03:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/examples-of-using-sketch-copy/m-p/11356775#M5592</guid>
      <dc:creator>OldSchoolMakerD</dc:creator>
      <dc:date>2022-08-12T23:03:23Z</dc:date>
    </item>
  </channel>
</rss>

