示例#1
0
def cleanpaths(toolpath, distancetol):
    #Clean up tool paths after cutting
    #Remove dead motions
    cleanedpath0 = copy.deepcopy(toolpath)

    for p in range(0, len(toolpath)):
        qcuts = 0
        for q in range(0, len(toolpath[p])):
            if cg.ptalmostequal(toolpath[p][q][0], toolpath[p][q][1],
                                distancetol):
                del (cleanedpath0[p][q - qcuts])
                qcuts = qcuts + 1

    cleanedpath1 = copy.deepcopy(cleanedpath0)

    #remove empty paths
    pcuts = 0
    for p in range(0, len(cleanedpath0)):
        if cleanedpath0[p] == []:
            del (cleanedpath1[p - pcuts])
            pcuts = pcuts + 1

    #Seperate broken baths into independent paths
    cleanedpath2 = copy.deepcopy(cleanedpath1)
    padds = 0
    for p in range(0, len(cleanedpath1)):
        t = 1
        for q in range(1, len(cleanedpath1[p])):
            if len(cleanedpath2) > 1:
                if not cg.ptalmostequal(cleanedpath2[p + padds][t - 1][1],
                                        cleanedpath2[p + padds][t][0],
                                        distancetol):
                    #construct residual
                    temppath = []
                    for r in range(t, len(cleanedpath2[p + padds])):
                        temppath.append(cleanedpath2[p + padds].pop(t))
                    cleanedpath2.insert(p + padds + 1, temppath)
                    padds = padds + 1
                    t = 0
                t = t + 1

    #Remove non-printing toolpaths
    cleanedpath3 = copy.deepcopy(cleanedpath2)
    pcut = 0
    for p in range(0, len(cleanedpath2)):
        psum = 0
        for q in range(0, len(cleanedpath2[p])):
            psum = psum + cleanedpath2[p][q][2]
        if psum == 0:
            del (cleanedpath3[p - pcut])
            pcut = pcut + 1
    return cleanedpath3
示例#2
0
def parse_endofmotion(toolpath, disttol):
    #adds an endofmotion parse at the end of a continuous motion regardless of material
    temptp = TPdeepcopy(toolpath)
    toolpath = temptp
    parsed_TP = []
    prevmotion = []
    lastmotion = 0
    parsecounter = 0
    for l in range(0, len(toolpath)):
        #check if this is a motion line
        linekeys = list(toolpath[l].keys())
        if 'startpoint' in linekeys:
            #Handle search for first motion
            if prevmotion == []:
                prevmotion = toolpath[l]
            #If there is a break in the motions
            elif not cg.ptalmostequal(prevmotion['endpoint'],
                                      toolpath[l]['startpoint'], disttol):
                parsed_TP.append({
                    'parse': 'endofmotion',
                    'motion': prevmotion
                })
                lastmotion += 1

            prevmotion = toolpath[l]
            lastmotion += (parsecounter + 1)
            parsecounter = 0
            #track position of last motion
        else:
            parsecounter += 1
        parsed_TP.append(toolpath[l])
    #handle last motion
    prevmotion = parsed_TP[lastmotion - 1]
    parsed_TP.insert(lastmotion, {
        'parse': 'endofmotion',
        'motion': prevmotion
    })

    return parsed_TP
示例#3
0
def helixpath (start, perimeter, pitch, overlap, zcurrent, ltl, helixid, history, distancetol, angletol, helixmat, supmat):
    #start - the start position on the perimeter though not necessarily a point in perimeter
    #perimenter - list of points that define the XY perimenter of the helix in CCW
    #pitch - the radian per layer
    #overlap - radian overlap with previous layer
    #zcurrent - zheight of current layer
    #ltl - layer to layer spacing
    #helixid - indentifier for the data specific to a individual helix
    #history - data for all helixes
    #distancetol and angletol - dimensional tolerances
    #Average pf points is used as center. This will generate errors if points are paritcularly imbalanced

    
    center = {'X': sum([perimeter[n]['X'] for n in range(0,len(perimeter))])/len(perimeter),'Y':sum([perimeter[n]['Y'] for n in range(0,len(perimeter))])/len(perimeter)}
    #print(str(center))
    if cg.pointinregion(center, perimeter, distancetol, angletol) == False:
        return 'Too concave'
    
    #find the maximum distance between the center and a point on the perimeter
    radius = max([(perimeter[n]['X']-center['X'])**2+(perimeter[n]['Y']-center['Y'])**2 for n in range(0,len(perimeter))])

    #construct overlap cycle
    perimeter_cycle = tpt.TPdeepcopy(perimeter)
    perimeter_cycle.append(perimeter_cycle[0])
    #Convert into 3D perimeter
    for p in range(0,len(perimeter)):
        perimeter_cycle[p]['Z']=zcurrent
    #print(str(perimeter_cycle))
    #Structural first-pass
    toolpath1 = []
    #Conductive
    toolpath2 = []
    #Structural second-pass
    toolpath3 = []
    #Next history
    newhistory= []
    
    #check if this is first call of helixpath for this specific helic
    if len(history) == helixid:
        #Start angle
        startangle = math.atan2( (start['Y']-center['Y']),(start['X']-center['X']) )
        #End angle
        endangle = startangle + pitch
        #angle at new overlap point
        overlap_startangle = endangle - (pitch/abs(pitch)) * overlap
        first = 1
    
    else:
        #last point of the history motion
        start = history[helixid][len(history[helixid])-1]['endpoint']
        #Start angle of this call
        startangle = math.atan2( (start['Y']-center['Y']),(start['X']-center['X']) ) 
        #End angle of this call
        endangle = startangle + pitch
        #angle at new overlap point
        overlap_startangle = endangle - (pitch/abs(pitch)) * overlap
        first = 0
        #append the motion from the previous layer
        for h in range(0,len(history[helixid])):
            toolpath2.append(history[helixid][h])
            #print(toolpath2)
    
    #Collect the intersecions with the perimeter and the associatated peritmeter segment
    #start point and perimeter section
    startray = [ center , {'X':radius * 1.1 *math.cos(startangle) + center['X'], 'Y':radius * 1.1 *math.sin(startangle) + center['Y']} ]
    intersections = []
    for s in range(0, len(perimeter)):
        periline = [{'X':perimeter_cycle[s]['X'],'Y':perimeter_cycle[s]['Y']} ,{'X':perimeter_cycle[s+1]['X'],'Y':perimeter_cycle[s+1]['Y']}]
        inter = cg.LineSegIntersect2D(startray , periline , distancetol , angletol)
        dimlist = list(perimeter[0].keys())
        if inter != 'none':
            if dimlist[0] in inter:
                intersections.append( [inter,s] )                
            elif inter[0] == 'colinear':
                intersections.append( [inter[1],s] )
                intersections.append( [inter[2],s] )

    #find intersection point closest to known start
    #print(intersections)
    #for i in range(0,len(intersections)):
    #    if ptalmostequal([intersections[i][0][0],intersections[i][0][1]], [start[0],start[1]],distancetol):
    #        startpoint = intersections[i]
    #startpoint[0].append(zcurrent)
    intersections.sort(key = lambda x: (x[0]['X']-start['X'])**2+(x[0]['Y']-start['Y'])**2)
    startpoint = intersections[0]
    startpoint[0]['Z']=zcurrent
    #print(toolpath2)
    #end point and perimeter section
    endray = [ center , {'X':radius * 1.1 *math.cos(endangle)  + center['X'], 'Y':radius * 1.1 *math.sin(endangle) + center['Y']} ]
    intersections = []
    for s in range(0, len(perimeter)):
        inter = cg.LineSegIntersect2D(endray , [perimeter_cycle[s],perimeter_cycle[s+1]] , distancetol , angletol)
        if inter != 'none':
            if dimlist[0] in inter:
                intersections.append( [inter,s] )                
            elif inter[0] == 'colinear':
                intersections.append( [inter[1],s] )
                intersections.append( [inter[2],s] )
    #find intersection point closest to the center
    intersections.sort(key = lambda x: (x[0]['X']-center['X'])**2+(x[0]['Y']-center['Y'])**2)
    endpoint = intersections[0]
    endpoint[0]['Z']=zcurrent
    #print(toolpath2)
    #overlap point an perimeter section
    overlapray = [ center , {'X':radius * 1.1 *math.cos(overlap_startangle)  + center['X'], 'Y':radius * 1.1 *math.sin(overlap_startangle) + center['Y']} ]
    intersections = []
    for s in range(0, len(perimeter)):
        inter = cg.LineSegIntersect2D(overlapray , [perimeter_cycle[s],perimeter_cycle[s+1]] , distancetol , angletol)
        if inter != 'none':
            if dimlist[0] in inter:
                intersections.append( [inter,s] )                
            elif inter[0] == 'colinear':
                intersections.append( [inter[1],s] )
                intersections.append( [inter[2],s] )
    #find intersection point closest to the center
    intersections.sort(key = lambda x: (x[0]['X']-center['X'])**2+(x[0]['Y']-center['Y'])**2)
    overlappoint = intersections[0]
    overlappoint[0]['Z']=zcurrent
    #Use the information above to construct the tool paths
  
    
    startsegment = startpoint[1]
    opass = 0
    epass = 0
    #print(startangle)
    #print(startpoint)
    #print(overlap_startangle)
    #print(overlappoint)
    #print(endangle)
    #print(endpoint)
    
    for s in range(0, len(perimeter)):
        #Determine the segment of perimeter is being investigated, starting with start segment
        segment = round((startsegment + (pitch/abs(pitch))*s) % len(perimeter))
        #Determine start point for this motion
        if toolpath2 == []:
            lstartpoint = startpoint[0]
        else:
            if s == 0:
                toolpath2.append({'startpoint':toolpath2[len(toolpath2)-1]['endpoint'], 'endpoint':startpoint[0] , 'material':helixmat})
            lstartpoint = toolpath2[len(toolpath2)-1]['endpoint']
            
        #print (lstartpoint)
        #if the overlap point has not been passed yet
        if opass == 0:
            #if the overlap point is in this segment
            if overlappoint[1]==segment:
                if (pitch/abs(pitch)) > 0:
                    sidestart2overlap = cg.linelength (perimeter_cycle[segment], overlappoint[0])
                    sidestart2start = cg.linelength (perimeter_cycle[segment], lstartpoint)
                else:
                    sidestart2overlap = cg.linelength (perimeter_cycle[segment+1], overlappoint[0])
                    sidestart2start = cg.linelength (perimeter_cycle[segment+1], lstartpoint)                    

                if sidestart2overlap > sidestart2start:
                    toolpath2.append({'startpoint':lstartpoint, 'endpoint':overlappoint[0] , 'material':helixmat})
                    opass = 1
                    lstartpoint = overlappoint[0]
            #if the overlap point is not in this segment
            else:
                if (pitch/abs(pitch)) > 0:
                    toolpath2.append({'startpoint':lstartpoint, 'endpoint':perimeter_cycle[segment+1] , 'material':helixmat})
                else:
                    toolpath2.append({'startpoint':lstartpoint, 'endpoint':perimeter_cycle[segment] , 'material':helixmat})
        if opass == 1 and epass == 0:
            #if the end point is in this segment
            if endpoint[1]==segment:
                toolpath2.append({'startpoint':lstartpoint, 'endpoint':endpoint[0] , 'material':helixmat})
                newhistory.append({'startpoint':lstartpoint, 'endpoint':endpoint[0] , 'material':helixmat})
                epass = 1
            #if the overlap point is not in this segment
            else:
                if (pitch/abs(pitch)) > 0:
                    toolpath2.append({'startpoint':lstartpoint, 'endpoint':perimeter_cycle[segment+1] , 'material':helixmat})            
                    newhistory.append({'startpoint':lstartpoint, 'endpoint':perimeter_cycle[segment+1] , 'material':helixmat})
                else:
                    toolpath2.append({'startpoint':lstartpoint, 'endpoint':perimeter_cycle[segment] , 'material':helixmat})            
                    newhistory.append({'startpoint':lstartpoint, 'endpoint':perimeter_cycle[segment] , 'material':helixmat})    
    if  first == 1:
        history.append(newhistory)
        #print(helixid, newhistory)
        return toolpath2
    
    #Construct first structural part
    #old overlap point an perimeter section
    if len(history[helixid])==1:
        ooverlappt = history[helixid][0]['startpoint']
    else:
        ooverlappt = history[helixid][0]['startpoint'] 
        
    ooverlapangle = math.atan2(ooverlappt['Y']-center['Y'],ooverlappt['X']-center['X'])
    ooverlapray = [ center , {'X':radius * 1.1 *math.cos(ooverlapangle)  + center['X'], 'Y':radius * 1.1 *math.sin(ooverlapangle) + center['Y']} ]
    
    intersections = []
    for s in range(0, len(perimeter)):
        inter = cg.LineSegIntersect2D(ooverlapray , [perimeter_cycle[s],perimeter_cycle[s+1]] , distancetol , angletol)
        if inter != 'none':
            if dimlist[0] in inter:
                intersections.append( [inter,s] )                
            elif inter[0] == 'colinear':
                intersections.append( [inter[1],s] )
                intersections.append( [inter[2],s] )
    #find intersection point closest to known start
    #for i in range(0,len(intersections)):
    #    if ptalmostequal([intersections[i][0][0],intersections[i][0][1]], [ooverlappt[0],ooverlappt[1]],distancetol):
    #        ooverlappoint = intersections[i]
    #ooverlappoint[0].append(zcurrent)        
    intersections.sort(key = lambda x: (x[0]['X']-ooverlappt['X'])**2+(x[0]['Y']-ooverlappt['Y'])**2)
    ooverlappoint = intersections[0]
    ooverlappoint[0]['Z']=zcurrent
    
    #print (ooverlappoint)
    startsegment = startpoint[1]
    oopass = 0
    #print(perimeter_cycle)
    for s in range(0, len(perimeter)+1):
        #Determine the segment of perimeter is being investigated, starting with start segment
        segment = round((startsegment + (pitch/abs(pitch))*s) % len(perimeter))
        #print(segment)
        #Determine start point for this motion
        if toolpath1 == []:
            lstartpoint = startpoint[0]
        else:
            lstartpoint = toolpath1[len(toolpath1)-1]['endpoint']
        #if the overlap point has not been passed yet
        if oopass == 0:
            #if the overlap point is in this segment
            if ooverlappoint[1]==segment:
                if (pitch/abs(pitch)) > 0:
                    sidestart2overlap = cg.linelength (perimeter_cycle[segment], overlappoint[0])
                    sidestart2start = cg.linelength (perimeter_cycle[segment], lstartpoint)
                else:
                    sidestart2overlap = cg.linelength (perimeter_cycle[segment+1], overlappoint[0])
                    sidestart2start = cg.linelength (perimeter_cycle[segment+1], lstartpoint)

                #Check to make sure the order is good
                if sidestart2overlap > sidestart2start:
                    toolpath1.append({'startpoint':lstartpoint, 'endpoint':ooverlappoint[0] , 'material':supmat})
                    oopass = 1
                else:
                    if (pitch/abs(pitch)) > 0:
                        toolpath1.append({'startpoint':lstartpoint, 'endpoint':perimeter_cycle[segment+1] , 'material':supmat})
                    else:
                        toolpath1.append({'startpoint':lstartpoint, 'endpoint':perimeter_cycle[segment] , 'material':supmat})                   
            #if the overlap point is not in this segment
            else:
                if (pitch/abs(pitch)) > 0:
                    toolpath1.append({'startpoint':lstartpoint, 'endpoint':perimeter_cycle[segment+1] , 'material':supmat})
                else:
                    toolpath1.append({'startpoint':lstartpoint, 'endpoint':perimeter_cycle[segment] , 'material':supmat})

    #Construct second structural part
    startsegment = startpoint[1]
    oopass = 0
    for s in range(0, len(perimeter)):
        #Determine the segment of perimeter is being investigated, starting with start segment
        segment = round((startsegment - (pitch/abs(pitch))*s) % len(perimeter))
        #Determine start point for this motion
        if toolpath3 == []:
            lstartpoint = startpoint[0]
        else:
            lstartpoint = toolpath3[len(toolpath3)-1]['endpoint']
        #if the overlap point has not been passed yet
        if oopass == 0:
            #if the overlap point is in this segment
            if ooverlappoint[1]==segment:
                toolpath3.append({'startpoint':lstartpoint, 'endpoint':ooverlappoint[0] , 'material':supmat})
                oopass = 1
            #if the overlap point is not in this segment
            else:
                if (pitch/abs(pitch)) > 0:
                    toolpath3.append({'startpoint':lstartpoint, 'endpoint':perimeter_cycle[segment] , 'material':supmat})
                else:
                    toolpath3.append({'startpoint':lstartpoint, 'endpoint':perimeter_cycle[segment+1] , 'material':supmat})
    history[helixid] = newhistory
    #print(helixid, newhistory)
    return[*toolpath1,*toolpath2,*toolpath3]
示例#4
0
def toolpcut(toolpath, boundry, keepoutside, distancetol, angletol):
    #Makes deepcopy of toolpath which will hold the motions that will survive the cut in some form
    temppath1 = TPdeepcopy(toolpath)

    #Construct boundary
    boundry_cycle = boundry[:]
    boundry_cycle.append(boundry[0])

    #Track number of lines cut
    cuts = 0  #initialize the number of lines cut

    #find and remove motion completely outside the region
    #Iterate through each line by line number
    for line in range(0, len(toolpath)):
        linekeys = str(toolpath[line].keys())
        #check if this is a motion line
        if 'startpoint' in linekeys:
            intersections = []  #reset intersections
            point1all = 0  #reset all intersect indicator for start point
            point2all = 0  #reset all intersect indicator for end point

            #check if the end points of a particular motion are within the region
            #pointinregion counts points on boundary as NOT in region
            inregion1 = cg.pointinregion(toolpath[line]['startpoint'], boundry,
                                         distancetol, angletol)
            inregion2 = cg.pointinregion(toolpath[line]['endpoint'], boundry,
                                         distancetol, angletol)

            #Collect intersection with boundary that are not colinear
            for b in range(0, len(boundry)):
                borderwall = [boundry_cycle[b], boundry_cycle[b + 1]]
                toolpathline = [
                    toolpath[line]['startpoint'], toolpath[line]['endpoint']
                ]
                intest = cg.LineSegIntersect2D(toolpathline, borderwall,
                                               distancetol, angletol)
                #Look for true intersections
                dimlist = list(boundry[0].keys())
                if dimlist[0] in intest:
                    intersections.append(intest)

            #print('Before ' +str(intersections))
            #remove repeats
            tempintest = []
            for element in intersections:
                unique = True
                for unique_element in tempintest:
                    if cg.ptalmostequal(unique_element, element, distancetol):
                        unique = False

                if unique:
                    tempintest.append(element)

            intersections = tempintest
            #print('After ' +str(intersections))
            #check for point intersections with boundary
            #make copies of the intersection list
            tempintest1 = copy.deepcopy(intersections)
            tempintest2 = copy.deepcopy(intersections)
            #reset cut trackers
            cuts1 = 0
            cuts2 = 0

            if len(intersections) != 0:
                #iterate though intersection list
                for w in range(0, len(intersections)):
                    #check for intersections that are equal to the end points of motion
                    if cg.ptalmostequal(toolpath[line]['startpoint'],
                                        intersections[w], distancetol):
                        #remove intersections from copy1 which are identical to start point
                        del (tempintest1[w - cuts1])
                        cuts1 = cuts1 + 1
                    if cg.ptalmostequal(toolpath[line]['endpoint'],
                                        intersections[w], distancetol):
                        #remove intersections from copy2 which are idential to end point
                        del (tempintest2[w - cuts2])
                        cuts2 = cuts2 + 1
                #If copy1 or copy2 lists are empty then set indicator for endpoint intesection with boundary
                if len(tempintest1) == 0:
                    point1all = 1
                if len(tempintest2) == 0:
                    point2all = 1

            #A motion to be completely removed must have one of the following
            #1. inregion1 and inregion2 = outvalue and there are no intersections
            #2. outvalue = 1 and inregion1 or inregion2 = outvalue and all intersection equal the end point where inregion = 0
            #3. outvalue = 0 and all intersections equal one of the motion endpoints
            '''
            keepoutside  inregion1  inregion2  point1all  point2all  len(intersections)==0
                T           T          T           0         0              T
                F           F          F           0         0              T
                F           F          F           
            '''
            #if both of the he endpoints of the motion are in the region being removed
            if inregion1 == keepoutside and inregion2 == keepoutside:
                #remove motions satisfying condition 1 (no intersection)
                if len(intersections) == 0:
                    del (temppath1[line - cuts])
                    cuts = cuts + 1
                #remove motions satisfying condition 3 (only applied when keeping inside)
                elif keepoutside == False:
                    #if one end is outside the region and the other is in the border though counted as being outside
                    if (point1all == 1
                            and point2all == 0) or (point1all == 0
                                                    and point2all == 1):
                        del (temppath1[line - cuts])
                        cuts = cuts + 1
            #remove motions satisfy condition 2
            if keepoutside == True:
                if inregion1 == False and inregion2 == True and point1all == 1:
                    del (temppath1[line - cuts])
                    cuts = cuts + 1
                if inregion1 == True and inregion2 == False and point2all == 1:
                    del (temppath1[line - cuts])
                    cuts = cuts + 1
                '''
                if inregion1 == False and inregion2 == False and len(tempintest1) == 1 and cg.ptalmostequal(toolpath[line]['endpoint'], tempintest1[0], distancetol) :
                    del(temppath1[line-cuts])
                    cuts = cuts + 1
                '''
    #Make another working copy to clean any complicating pointing
    temppath2 = copy.deepcopy(temppath1)
    motionadds = 0  #initialize the number of lines added

    #Cut back intersecting lines
    for line in range(0, len(temppath1)):
        #Check for intersections with boundary
        intersections = []
        for b in range(0, len(boundry)):
            borderwall = [boundry_cycle[b], boundry_cycle[b + 1]]
            temppath1line = [
                temppath1[line]['startpoint'], temppath1[line]['endpoint']
            ]
            intest = cg.LineSegIntersect2D(temppath1line, borderwall,
                                           distancetol, angletol)
            #Construct list of intersections, both normal and colinear
            if intest != 'none':
                intersections.append(intest)
        #Break up motion across boundry
        #check if motion intersects
        inregion1 = cg.pointinregion(temppath1[line]['startpoint'], boundry,
                                     distancetol, angletol)
        inregion2 = cg.pointinregion(temppath1[line]['endpoint'], boundry,
                                     distancetol, angletol)
        #print(inregion1,inregion2, p,q)
        if intersections != []:

            #line startin boundry and moving out of printed region should have already been removed

            #Collect all intersection including colinear ones
            newintersections = []
            dimlist = list(boundry[0].keys())
            for e in range(0, len(intersections)):
                if dimlist[0] in intersections[e]:
                    newintersections.append(intersections[e])
                elif intersections[e][0] == 'colinear':
                    newintersections.append(intersections[e][1])
                    newintersections.append(intersections[e][2])

            intersections = newintersections

            #sort by distance from startpoint
            intersections.sort(key=lambda x: (x[dimlist[0]] - temppath1[line][
                'startpoint'][dimlist[0]])**2 + (x[dimlist[1]] - temppath1[
                    line]['startpoint'][dimlist[1]])**2)
            #check if motion starts in boundry or on edge then set starting state of motion
            #print(str(intersections[0]) +' ' + str(temppath1[line]['startpoint']))
            if inregion1 == True or cg.ptalmostequal(
                    intersections[0], temppath1[line]['startpoint'],
                    distancetol):
                start = not keepoutside
            else:
                start = keepoutside
            #if start of motion is on boundry then remove that point from the intercept list to avoid double counting it
            #print(intersections)

            #if the motion starts on
            if start == True:
                #add the start point to the pointlist
                pointlist = [temppath1[line]['startpoint']]
            #if the motion starts off
            else:
                pointlist = []

            #add all the remaining intersection points that are not equal to the end or start points
            for e in range(0, len(intersections)):
                if (not cg.ptalmostequal(
                        intersections[e], temppath1[line]['startpoint'],
                        distancetol)) and (not cg.ptalmostequal(
                            intersections[e], temppath1[line]['endpoint'],
                            distancetol)):
                    pointlist.append(intersections[e])

            #add the motion end point
            pointlist.append(temppath1[line]['endpoint'])

            #sort the list based on distance from start of motion
            dimlist = list(pointlist[0].keys())
            pointlist.sort(key=lambda x: (x[dimlist[0]] - temppath1[line][
                'startpoint'][dimlist[0]])**2 + (x[dimlist[1]] - temppath1[
                    line]['startpoint'][dimlist[1]])**2)

            #remove repeated values
            newpointlist = [pointlist[0]]
            cuts = 0
            for e in range(1, len(pointlist)):
                if not cg.ptalmostequal(pointlist[e], pointlist[e - 1],
                                        distancetol):
                    newpointlist.append(pointlist[e])
            pointlist = newpointlist
            #print(pointlist)
            #print(inregion1, start, pointlist)
            for i in range(0, len(pointlist)):
                #Alternate lines
                if i % 2 == 1:
                    #modify the first line
                    if i == 1:
                        temppath2[line +
                                  motionadds]['startpoint'] = pointlist[i - 1]
                        temppath2[line + motionadds]['endpoint'] = pointlist[i]
                    else:
                        tempmotion = {
                            'startpoint': pointlist[i - 1],
                            'endpoint': pointlist[i],
                            'material':
                            temppath2[line + motionadds]['material']
                        }
                        temppath2.insert(line + 1 + motionadds, tempmotion)
                        motionadds = motionadds + 1

    return temppath2