<?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: Possible Bug in trim in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5454522#M21712</link>
    <description>&lt;P&gt;Using your code as-is it creates the triangle with the mid-line but fails to trim the top and bottom lines.&amp;nbsp; However, if I uncomment the line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; trimPoint.x += iD/2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get the expected results.&amp;nbsp; This makes sense to me because specifying the trim point at the origin is ambiguous.&amp;nbsp; When trimming the bottom line and specifying the origin as the trim point it could assume you want to trim to the top line, which results in no change.&amp;nbsp; Moving the point in the positive direction, anywhere along the red area I've highlighted below should perorm the trim as expected and that's the result I'm seeing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/147123iC12AD0DC015C9084/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="ValidPoint.png" title="ValidPoint.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's what I get after uncommenting the line to modify the X coordinate of the trim point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/147124i09D99ABD2466B6C3/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Result.png" title="Result.png" /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Dec 2014 16:04:43 GMT</pubDate>
    <dc:creator>ekinsb</dc:creator>
    <dc:date>2014-12-29T16:04:43Z</dc:date>
    <item>
      <title>Possible Bug in trim</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5453295#M21707</link>
      <description>&lt;P&gt;I created a triangle of sketchLines with one vertex at the origin of the sketch. &amp;nbsp;I then created a line that intersects (and extends past)&amp;nbsp;both sides that share the origin at the vertex. &amp;nbsp;I can use trim on the intersecting line and give it the Point3D of either end of the intersecting line and it functions fine. &amp;nbsp;However, when I try to use trim on either sketchLine that contains the origin and give it the Point3D of the origin, it does not trim the lines. &amp;nbsp;I have give it some point between the origin and the intersecting line to work. &amp;nbsp;Not sure if this is a bug or just a result of the algorithm that finds the distance to the trim side.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Dec 2014 19:13:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5453295#M21707</guid>
      <dc:creator>dirktheeng</dc:creator>
      <dc:date>2014-12-26T19:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Possible Bug in trim</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5453424#M21708</link>
      <description>&lt;P&gt;Hi Dirk,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure I fully understand what you're trying to do?&amp;nbsp; Can you post of screenshot of the geometry and what you're trying to trim?&amp;nbsp; Can&amp;nbsp; you perform the desired trim interactively in Fusion?&lt;/P&gt;</description>
      <pubDate>Sat, 27 Dec 2014 02:15:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5453424#M21708</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2014-12-27T02:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: Possible Bug in trim</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5453739#M21709</link>
      <description>&lt;P&gt;Here's the code that fails to trim unless you move the trim point off zero,zero in the +x direction&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you uncomment the "trimPoint.x += iD/2" line, it will work as expected&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#Author Dirk Van Essendelft
#Copyright 12/25/2014 21st Century Woodworking

import adsk.core, adsk.fusion, traceback, math, time

class SegRing:
    
    def __init__(self):
        try:
            self.app = adsk.core.Application.get()
            self.core = adsk.core
            self.ui = self.app.userInterface
            self.product = self.app.activeProduct
            self.design = adsk.fusion.Design.cast(self.product)
            self.rootComp = self.design.rootComponent
            self.sketches = self.rootComp.sketches
            self.pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062
            self.globalOrigin = adsk.core.Point3D.create(0,0,0)
            self.extrudes = self.rootComp.features.extrudeFeatures
        except:
            if self.ui:
                self.ui.messageBox('Problem in __init__:\n{}'.format(traceback.format_exc()))
                
    def createSegmentComp(self,n,iD,oD,height):

        newOcc = self.rootComp.occurrences.addNewComponent(adsk.core.Matrix3D.create())
        comp = newOcc.component
        comp._set_name('Single_Segment')
        sketches = comp.sketches
        sketch = sketches.add(comp.xZConstructionPlane)
        sketch._set_isVisible(False)
        sketch._set_name('SegmentOutline')
        sketchLines = sketch.sketchCurves.sketchLines
        sketchPoints = sketch.sketchPoints
        angle = 2.0*self.pi/n
        halfAngle = angle/2.0
        drawingOrigin = self.globalOrigin.copy()
        sketchPointOrigin = sketchPoints.add(drawingOrigin)
        sketchPointOrigin._set_isFixed(True)
        
        #Create Lower Line
        lowerLineStart = drawingOrigin.copy()
        lowerLineEnd = drawingOrigin.copy()
        lowerLineEnd.x = lowerLineEnd.x + math.cos(halfAngle) * oD * 2
        lowerLineEnd.y = lowerLineEnd.y - math.sin(halfAngle) * oD * 2
        lowerLine = sketchLines.addByTwoPoints(lowerLineStart,lowerLineEnd)
        
        #Create Upper Line        
        upperLineStart = drawingOrigin.copy()
        upperLineEnd = drawingOrigin.copy()
        upperLineEnd.x = upperLineEnd.x + math.cos(halfAngle) * oD * 2
        upperLineEnd.y = upperLineEnd.y + math.sin(halfAngle) * oD * 2
        upperLine = sketchLines.addByTwoPoints(upperLineStart,upperLineEnd)
        
        #Create Outter Line
        oDLineStart = drawingOrigin.copy()
        oDLineStart.x += oD
        oDLineStart.y += oD
        oDLineEnd  = oDLineStart.copy()
        oDLineEnd.y -= 2 * oD
        odLine = sketchLines.addByTwoPoints(oDLineStart,oDLineEnd)
        
        #Create Inner Line        
        idLineStart = drawingOrigin.copy()
        idLineEnd = drawingOrigin.copy()
        idLineStart.x = math.cos(halfAngle) * iD
        idLineStart.y = -1.0 * oD
        idLineEnd.x = idLineStart.x
        idLineEnd.y = -1.0 * idLineStart.y
        idLine = sketchLines.addByTwoPoints(idLineStart,idLineEnd)
        
        #Trim Lines to Create Trapizoid
        lowerLine.trim(lowerLineEnd)
        upperLine.trim(upperLineEnd)
        odLine.trim(oDLineStart)
        odLine.trim(oDLineEnd)
        idLine.trim(idLineStart)
        idLine.trim(idLineEnd)
                
#        lineReturn = lowerLine.breakCurve(idLine.startSketchPoint.geometry,True)
#        print(lineReturn.count)

        trimPoint = upperLine.startSketchPoint.geometry.copy()
#        trimPoint.x += iD/2
        lowerLine.trim(trimPoint)
        upperLine.trim(trimPoint)

        
def main():
    try:
        
        nSeg = 8          # Number of Segments
        inerDia = 3          # inner diameter
        outterDia = 4          # outter diameter
        ringHeight = 1      # height of ring
        
        sR = SegRing()
        sR.createSegmentComp(nSeg,inerDia,outterDia,ringHeight)

    except:
        sR.ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
            

main()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Dec 2014 23:30:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5453739#M21709</guid>
      <dc:creator>dirktheeng</dc:creator>
      <dc:date>2014-12-27T23:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Possible Bug in trim</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5453806#M21710</link>
      <description>&lt;P&gt;BTW, the code still failed if I moved off the zero, zero position to the negative x direction. &amp;nbsp;According to the docs, I should be able to feed it a Poind3D object the is closest to the side of the trim and have it function correctly. &amp;nbsp;In this example, any -x position should be closer than any point that is betweeen 0 and cos(iD) so it should trim the line, but it doesnt.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Dec 2014 05:53:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5453806#M21710</guid>
      <dc:creator>dirktheeng</dc:creator>
      <dc:date>2014-12-28T05:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Possible Bug in trim</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5454255#M21711</link>
      <description>&lt;P&gt;I think I stated that incorrectly. &amp;nbsp;any -x position should be closer to the side of the trim line than any point with an x value grater than cos(iD). &amp;nbsp;Basically I would expect it to trim correctly with any point with an x less than cos(iD) wich would include 0,0 or anything y,&amp;lt;0 but it doesn't.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Dec 2014 06:26:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5454255#M21711</guid>
      <dc:creator>dirktheeng</dc:creator>
      <dc:date>2014-12-29T06:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Possible Bug in trim</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5454522#M21712</link>
      <description>&lt;P&gt;Using your code as-is it creates the triangle with the mid-line but fails to trim the top and bottom lines.&amp;nbsp; However, if I uncomment the line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; trimPoint.x += iD/2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get the expected results.&amp;nbsp; This makes sense to me because specifying the trim point at the origin is ambiguous.&amp;nbsp; When trimming the bottom line and specifying the origin as the trim point it could assume you want to trim to the top line, which results in no change.&amp;nbsp; Moving the point in the positive direction, anywhere along the red area I've highlighted below should perorm the trim as expected and that's the result I'm seeing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/147123iC12AD0DC015C9084/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="ValidPoint.png" title="ValidPoint.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's what I get after uncommenting the line to modify the X coordinate of the trim point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/147124i09D99ABD2466B6C3/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Result.png" title="Result.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Dec 2014 16:04:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5454522#M21712</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2014-12-29T16:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: Possible Bug in trim</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5454778#M21713</link>
      <description>&lt;P&gt;I kind of disagree. &amp;nbsp;There should be no ambiguity becasue I am calling&amp;nbsp;the trim method within the sketchLine instance. &amp;nbsp;To me that means the trim method is only going to ack on that specific sketchLine instance. &amp;nbsp;How is that ambiguous as to which sketchLine is going to get trimmed? &amp;nbsp;Thats why there are two calls to trim for each sketchLine instance, one for lowerLine and one for upperLine. &amp;nbsp;How can a method in one instance act on another?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Dec 2014 19:56:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5454778#M21713</guid>
      <dc:creator>dirktheeng</dc:creator>
      <dc:date>2014-12-29T19:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Possible Bug in trim</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5455664#M21714</link>
      <description>&lt;P&gt;I wasn't clear in my last post.&amp;nbsp; Which line to trim isn't ambiguous, but where to trim the line is.&amp;nbsp; The trim operation finds all entities that intersect the entity you want to trim and then you specify the section between intersections to be trimmed by specifying a point in the area to trim.&amp;nbsp; What's ambiguous is if this point is the same as one of the intersection points.&amp;nbsp; Fusion doesn't know which side of the point to remove.&amp;nbsp; In your case the origin is the same point as the intersection of the bottom and top lines.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Dec 2014 20:56:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5455664#M21714</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2014-12-30T20:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: Possible Bug in trim</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5455671#M21715</link>
      <description>&lt;P&gt;That makes sense to me. &amp;nbsp;I understand now. &amp;nbsp;Thats why a negative x value wouldn't work eigher because there would be nothing to trim on that side of the intersection point at the origin. &amp;nbsp;I get it now. &amp;nbsp;Wish I could read the code for the operations. &amp;nbsp;It would make life a bit easier.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Dec 2014 21:04:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/possible-bug-in-trim/m-p/5455671#M21715</guid>
      <dc:creator>dirktheeng</dc:creator>
      <dc:date>2014-12-30T21:04:21Z</dc:date>
    </item>
  </channel>
</rss>

