FB CAD

User projects written in or related to FreeBASIC.
Post Reply
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: FB CAD

Post by owen »

the data at the bottom came from fbcadcam's latest export feature.
when you save drawings, you can find the dot dat files in the bin folder.
more discussion about this can be found at http://www.thejoyfulprogrammer.com/qb64 ... hp?tid=981
Image
draw-entities-data-move-rotate-chain-sprockets.bas

Code: Select all

'chain and sprockets
'the initial drawing for the sprockets and chain links
'were drawn using fbcadcam.
'owen reese, fbcadcam.com opreese@gmail.com

'up and down arrow keys speed up and slow down
'mouse wheel zoom in and out
'press esc to end.

Declare Function mymod(n As Double,m As Integer) As Double
Declare Sub show_entities()
Declare Sub move_entities(move_x As Double, move_y As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
Declare Sub move_circle_entities(move_x As Double, move_y As Double, Cs As Integer, Ce As Integer)
Declare Sub move_line_entities(move_x As Double, move_y As Double, Ls As Integer,Le As Integer)
Declare Sub rotate_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
Declare Sub rotate_circle_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Cs As Integer, Ce As Integer)
Declare Sub rotate_line_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Ls As Integer,Le As Integer)
Declare Sub plotellipse(ex1 As Double,ey1 As Double,er1 As Double,estart As Double,eend As Double,er2 As Double,eangle As Double)
Declare Sub read_entity_data()
Declare Sub zoomoutpan()
Declare Sub zoominpan()

Const pi As double = 4 * Atn(1)

Dim Shared As Integer linesc,circlesc
Dim Shared As Double lines()
Dim Shared As Double circles()
Dim Shared As Double chain_init()
Dim As Integer i,j,k,m,n,c,cc,speed

Dim Shared As Integer sprocket_1_linesc_start,sprocket_1_linesc_end,sprocket_1_circlesc_start,sprocket_1_circlesc_end
Dim Shared As Integer sprocket_2_linesc_start,sprocket_2_linesc_end,sprocket_2_circlesc_start,sprocket_2_circlesc_end
Dim As Double sprocket1x,sprocket1y,sprocket1r,sprocket2x,sprocket2y,sprocket2r

Dim Shared As Integer chain_link_piece_1_circlesc_start,chain_link_piece_1_circlesc_end
Dim Shared As Integer chain_link_piece_2_circlesc_start,chain_link_piece_2_circlesc_end
Dim As Integer chain_link_piece_3_circlesc_start,chain_link_piece_3_circlesc_end
Dim As Double clpx,clpy,clpx1,clpy1,clpx2,clpy2
Dim As Integer clpi,linksc,clp_total_entity_count,clp1cs,clp1ce,clp2cs,clp2ce,clp3cs,clp3ce

Dim As Double ac,angle,a1x,a1y,a2x,a2y

Dim As Double cpath(1079,2)

Dim Shared As Integer wx1,wy1,wx2,wy2,wzoom,wzoomt,maxzoomin,maxzoomout
Dim Shared As Integer mousex,mousey,mousew,mousewp,mouse_in_window

wzoom=20
wzoomt=20
maxzoomin=100
maxzoomout=10000


wx1=0
wy1=0
wx2=600
wy2=600

ScreenRes 600,600
window (wx1,wy1)-(wx2,wy2)
linesc=0
circlesc=0

sprocket_1_linesc_start=linesc+1
sprocket_1_circlesc_start=circlesc+1
read_entity_data
sprocket_1_linesc_end=linesc
sprocket_1_circlesc_end=circlesc

sprocket_2_linesc_start=linesc+1
sprocket_2_circlesc_start=circlesc+1
read_entity_data
sprocket_2_linesc_end=linesc
sprocket_2_circlesc_end=circlesc

sprocket1x=170
sprocket1y=300
sprocket1r=95.88679832249493
sprocket2x=467.592372833434
sprocket2y=300
sprocket2r=57.9555495773441



chain_link_piece_1_circlesc_start=circlesc+1
read_entity_data
chain_link_piece_1_circlesc_end=circlesc

chain_link_piece_2_circlesc_start=circlesc+1
read_entity_data
chain_link_piece_2_circlesc_end=circlesc

chain_link_piece_3_circlesc_start=circlesc+1
read_entity_data
chain_link_piece_3_circlesc_end=circlesc

clp_total_entity_count=chain_link_piece_3_circlesc_end-chain_link_piece_1_circlesc_start+1
linksc=17
ReDim Preserve circles(circlesc+clp_total_entity_count*linksc,7)
'make 17 more coppies of each link piece for a total of 18 links
For i = 1 To linksc
    For j=chain_link_piece_1_circlesc_start To chain_link_piece_3_circlesc_end
        circlesc+=1
        For k=0 To 7
            circles(circlesc,k)=circles(j,k)
        Next
    Next
Next

ReDim chain_init(clp_total_entity_count*(linksc+1),7)
c=0
For i = 0 To linksc
    For j=chain_link_piece_1_circlesc_start To chain_link_piece_3_circlesc_end
        c+=1
        For k=0 To 7
            chain_init(c,k)=circles(j,k)
        Next
    Next
Next

move_entities(170,300,sprocket_1_linesc_start,sprocket_1_linesc_end,sprocket_1_circlesc_start,sprocket_1_circlesc_end)
move_entities(467.4,300,sprocket_2_linesc_start,sprocket_2_linesc_end,sprocket_2_circlesc_start,sprocket_2_circlesc_end)


'build a path for the chain to follow
a1x=sprocket1x+Cos(90*pi/180)*sprocket1r
a1y=sprocket1y+Sin(90*pi/180)*sprocket1r
a2x=sprocket2x+cos(90*pi/180)*sprocket2r
a2y=sprocket2y+Sin(90*pi/180)*sprocket2r
angle=atan2(a2y-a1y,a2x-a1x)/pi*180
'from top left to top right
c=-1
For i = 1 To 300
    c+=1
    cpath(c,1)=a1x+cos(angle*pi/180)*(i-1)
    cpath(c,2)=a1y+Sin(angle*pi/180)*(i-1)
Next
'around small sprocket
For i = 1 To 180
    c+=1
    cpath(c,1)=sprocket2x+Cos((90-i+1)*pi/180)*sprocket2r
    cpath(c,2)=sprocket2y+Sin((90-i+1)*pi/180)*sprocket2r
Next
'from bottom right to bottom left
a1x=sprocket2x+Cos(270*pi/180)*sprocket2r
a1y=sprocket2y+Sin(270*pi/180)*sprocket2r
a2x=sprocket1x+cos(270*pi/180)*sprocket1r
a2y=sprocket1y+Sin(270*pi/180)*sprocket1r
angle=atan2(a2y-a1y,a2x-a1x)/pi*180
For i = 1 To 300
    c+=1
    cpath(c,1)=a1x+cos(angle*pi/180)*(i-1)
    cpath(c,2)=a1y+Sin(angle*pi/180)*(i-1)
Next
'around the big sprockte
For i = 1 To 300
    c+=1
    cpath(c,1)=sprocket1x+Cos((270-(i-1)*.6)*pi/180)*sprocket1r
    cpath(c,2)=sprocket1y+Sin((270-(i-1)*.6)*pi/180)*sprocket1r
Next

For i=0 To linksc
    clp1cs=chain_link_piece_1_circlesc_start+clp_total_entity_count*i
    clp1ce=chain_link_piece_1_circlesc_end+clp_total_entity_count*i
    clp2cs=chain_link_piece_2_circlesc_start+clp_total_entity_count*i
    clp2ce=chain_link_piece_2_circlesc_end+clp_total_entity_count*i
    clp3cs=chain_link_piece_3_circlesc_start+clp_total_entity_count*i
    clp3ce=chain_link_piece_3_circlesc_end+clp_total_entity_count*i
    
    a1x=cpath(i*60,1)
    a1y=cpath(i*60,2)
    a2x=cpath(i*60+30,1)
    a2y=cpath(i*60+30,2)
    angle=atan2(a2y-a1y,a2x-a1x)/pi*180
    clpx=a1x
    clpy=a1y
    move_circle_entities(clpx,clpy,clp1cs,clp1ce)
    move_circle_entities(clpx,clpy,clp3cs,clp3ce)
    rotate_circle_entities(clpx,clpy,angle,clp1cs,clp1ce)
    rotate_circle_entities(clpx,clpy,angle,clp3cs,clp3ce)

    Select Case i
        Case 0 To 16
            a1x=cpath(i*60+30,1)
            a1y=cpath(i*60+30,2)
            a2x=cpath(i*60+60,1)
            a2y=cpath(i*60+60,2)
            angle=atan2(a2y-a1y,a2x-a1x)/pi*180
            clpx=a1x
            clpy=a1y
            move_circle_entities(clpx,clpy,clp2cs,clp2ce)
            rotate_circle_entities(clpx,clpy,angle,clp2cs,clp2ce)
        Case 17
            a1x=cpath(i*60+30,1)
            a1y=cpath(i*60+30,2)
            a2x=cpath(0,1)
            a2y=cpath(0,2)
            angle=atan2(a2y-a1y,a2x-a1x)/pi*180
            clpx=a1x
            clpy=a1y
            move_circle_entities(clpx,clpy,clp2cs,clp2ce)
            rotate_circle_entities(clpx,clpy,angle,clp2cs,clp2ce)
    End Select
Next

show_entities
Sleep 1000

speed=1
Do
    c=0
    For j=1 To 360 Step speed
        Select Case InKey
            Case Chr(27),Chr(255)+"k"
                End
            Case Chr(255)+"H"
                If speed<10 Then
                    rotate_entities(sprocket1x,sprocket1y,-.6*(361-j),sprocket_1_linesc_start,sprocket_1_linesc_end,sprocket_1_circlesc_start,sprocket_1_circlesc_end)
                    rotate_entities(sprocket2x,sprocket2y,-1*(361-j),sprocket_2_linesc_start,sprocket_2_linesc_end,sprocket_2_circlesc_start,sprocket_2_circlesc_end)
                    speed+=1
                    Exit For
                EndIf
            Case Chr(255)+"P"
                If speed>1 Then
                    rotate_entities(sprocket1x,sprocket1y,-.6*(361-j),sprocket_1_linesc_start,sprocket_1_linesc_end,sprocket_1_circlesc_start,sprocket_1_circlesc_end)
                    rotate_entities(sprocket2x,sprocket2y,-1*(361-j),sprocket_2_linesc_start,sprocket_2_linesc_end,sprocket_2_circlesc_start,sprocket_2_circlesc_end)
                    speed-=1
                    Exit For
                EndIf
        End Select
        mouse_in_window=GetMouse(mousex,mousey,mousew)
        If mouse_in_window=0 Then
            mousey=600-mousey
            mousex=wx1+(wx2-wx1)*(mousex/600)
            mousey=wy1+(wy2-wy1)*(mousey/600)
            If mousew<>mousewp Then
                If mousew>mousewp Then
                    zoominpan
                Else
                    zoomoutpan
                EndIf
                mousewp=mousew
                ScreenLock
                window (wx1,wy1)-(wx2,wy2)
                ScreenUnLock
            EndIf
        EndIf
        
        'rotate the sprockets
        rotate_entities(sprocket1x,sprocket1y,-.6*speed,sprocket_1_linesc_start,sprocket_1_linesc_end,sprocket_1_circlesc_start,sprocket_1_circlesc_end)
        rotate_entities(sprocket2x,sprocket2y,-1*speed,sprocket_2_linesc_start,sprocket_2_linesc_end,sprocket_2_circlesc_start,sprocket_2_circlesc_end)
        'put them back to zero
        cc=0
        For i = 0 To linksc
            For m=chain_link_piece_1_circlesc_start To chain_link_piece_3_circlesc_end
                cc+=1
                For n=0 To 7
                    circles(chain_link_piece_1_circlesc_start+cc-1,n)=chain_init(cc,n)
                Next
            Next
        Next
        
        c+=speed
        
        'If c>=31 Then c=speed
        'move them up on the sprockets
        For i=0 To linksc
            clp1cs=chain_link_piece_1_circlesc_start+clp_total_entity_count*i
            clp1ce=chain_link_piece_1_circlesc_end+clp_total_entity_count*i
            clp2cs=chain_link_piece_2_circlesc_start+clp_total_entity_count*i
            clp2ce=chain_link_piece_2_circlesc_end+clp_total_entity_count*i
            clp3cs=chain_link_piece_3_circlesc_start+clp_total_entity_count*i
            clp3ce=chain_link_piece_3_circlesc_end+clp_total_entity_count*i
            Select Case i
                Case 0 To 16
                    a1x=cpath((i*60+c) Mod 1080,1)
                    a1y=cpath((i*60+c) Mod 1080,2)
                    a2x=cpath((i*60+30+c) Mod 1080,1)
                    a2y=cpath((i*60+30+c) Mod 1080,2)
                    angle=atan2(a2y-a1y,a2x-a1x)/pi*180
                    clpx=a1x
                    clpy=a1y
                    move_circle_entities(clpx,clpy,clp1cs,clp1ce)
                    move_circle_entities(clpx,clpy,clp3cs,clp3ce)
                    rotate_circle_entities(clpx,clpy,angle,clp1cs,clp1ce)
                    rotate_circle_entities(clpx,clpy,angle,clp3cs,clp3ce)
                    
                    a1x=cpath((i*60+30+c) Mod 1080 ,1)
                    a1y=cpath((i*60+30+c) Mod 1080 ,2)
                    a2x=cpath((i*60+60+c) Mod 1080 ,1)
                    a2y=cpath((i*60+60+c) Mod 1080 ,2)
                    angle=atan2(a2y-a1y,a2x-a1x)/pi*180
                    clpx=a1x
                    clpy=a1y
                    move_circle_entities(clpx,clpy,clp2cs,clp2ce)
                    rotate_circle_entities(clpx,clpy,angle,clp2cs,clp2ce)
                Case 17
                    a1x=cpath((i*60+c) Mod 1080 ,1)
                    a1y=cpath((i*60+c) Mod 1080 ,2)
                    a2x=cpath((i*60+30+c) Mod 1080,1)
                    a2y=cpath((i*60+30+c) Mod 1080,2)
                    angle=atan2(a2y-a1y,a2x-a1x)/pi*180
                    clpx=a1x
                    clpy=a1y
                    move_circle_entities(clpx,clpy,clp1cs,clp1ce)
                    move_circle_entities(clpx,clpy,clp3cs,clp3ce)
                    rotate_circle_entities(clpx,clpy,angle,clp1cs,clp1ce)
                    rotate_circle_entities(clpx,clpy,angle,clp3cs,clp3ce)
                    
                    a1x=cpath((i*60+30+c) Mod 1080,1)
                    a1y=cpath((i*60+30+c) Mod 1080,2)
                    a2x=cpath((i*60+60+c) Mod 1080,1)
                    a2y=cpath((i*60+60+c) Mod 1080,2)
                    angle=atan2(a2y-a1y,a2x-a1x)/pi*180
                    clpx=a1x
                    clpy=a1y
                    move_circle_entities(clpx,clpy,clp2cs,clp2ce)
                    rotate_circle_entities(clpx,clpy,angle,clp2cs,clp2ce)
            End Select
        Next
        show_entities
        Sleep 1
    Next
Loop
End

Sub show_entities()
    ScreenLock
    Cls
    Dim As Integer i,clr
    clr=15
    For i=1 To linesc
        Select Case i
            Case sprocket_1_linesc_start
                clr=14
            Case sprocket_2_linesc_start
                clr=15            
        End Select
        Line(lines(i,1),lines(i,2))-(lines(i,3),lines(i,4)),clr
    Next
    For i=1 To circlesc
        Select Case i
            Case sprocket_1_circlesc_start
                clr=14            
            Case sprocket_1_circlesc_start
                clr=15            
            Case chain_link_piece_1_circlesc_start
                clr=3
        End Select
        Select Case circles(i,0)
            Case 1
                Circle(circles(i,1),circles(i,2)),circles(i,3),clr
            Case 2
                Circle(circles(i,1),circles(i,2)),circles(i,3),clr,circles(i,4),circles(i,5)
            Case 3
                plotellipse(circles(i,1),circles(i,2),circles(i,3),circles(i,4),circles(i,5),circles(i,6),circles(i,7))
        End Select
    Next
    ScreenUnLock
End Sub

Function mymod(n As Double,m As Integer) As Double
    Select Case n
        Case 0
            mymod = 0
        Case CDbl(m)
            mymod = CDbl(m)
        Case Else
            If InStr(Str(n),"e")<>0 Then
                mymod=0
            Else
                If InStr(Str(n),".")<>0 Then
                    mymod=Val(Str(val(Mid(Str(n),1,InStr(Str(n),".")-1)) Mod m)+"."+Mid(Str(n),InStr(Str(n),".")+1))
                Else
                    mymod = (n Mod m)
                EndIf
            End If
    End Select
End Function


Sub move_entities(move_x As Double, move_y As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
    Dim As Integer i
    for i = Ls to Le
        lines(i,1)+=move_x
        lines(i,2)+=move_y
        lines(i,3)+=move_x
        lines(i,4)+=move_y
    Next
    For i = Cs To Ce
        circles(i,1)+=move_x
        circles(i,2)+=move_y
    Next
End Sub

Sub move_circle_entities(move_x As Double, move_y As Double, Cs As Integer, Ce As Integer)
    Dim As Integer i
    For i = Cs To Ce
        circles(i,1)+=move_x
        circles(i,2)+=move_y
    Next
End Sub

Sub move_line_entities(move_x As Double, move_y As Double, Ls As Integer,Le As Integer)
    Dim As Integer i
    for i = Ls to Le
        lines(i,1)+=move_x
        lines(i,2)+=move_y
        lines(i,3)+=move_x
        lines(i,4)+=move_y
    Next
End Sub









Sub rotate_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
    Dim As Integer i,j
    Dim As Double x1,y1,x2,y2,x1p,y1p,x2p,y2p
    Dim As Double arcangle,arcstart,arcend,arcendpoint1x,arcendpoint1y,arcendpoint2x,arcendpoint2y
    
    for i = Ls to Le
        x1p=lines(i,1)-pivot_pt_x
        y1p=lines(i,2)-pivot_pt_y
        x2p=lines(i,3)-pivot_pt_x
        y2p=lines(i,4)-pivot_pt_y
        lines(i,1)=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,2)=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        lines(i,3)=x2p*cos(rotation_angle*pi/180) - y2p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,4)=y2p*cos(rotation_angle*pi/180) + x2p*sin(rotation_angle*pi/180)+pivot_pt_y
    Next

    For i = Cs To Ce
        x1=circles(i,1)
        y1=circles(i,2)
        x1p=x1-pivot_pt_x
        y1p=y1-pivot_pt_y
        x1=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        y1=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        Select Case circles(i,0)
            Case 1
                circles(i,1)=x1
                circles(i,2)=y1
            Case 2
                arcendpoint1x=circles(i,1)+cos(circles(i,4))*circles(i,3)
                arcendpoint1y=circles(i,2)+sin(circles(i,4))*circles(i,3)
                arcendpoint2x=circles(i,1)+cos(circles(i,5))*circles(i,3)
                arcendpoint2y=circles(i,2)+sin(circles(i,5))*circles(i,3)
                x1p=arcendpoint1x-pivot_pt_x
                y1p=arcendpoint1y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcstart=arcangle*PI/180
                x1p=arcendpoint2x-pivot_pt_x
                y1p=arcendpoint2y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcend=arcangle*PI/180
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,4)=arcstart
                circles(i,5)=arcend
            Case 3,4'rotating ellipses
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,7)=mymod(circles(i,7)+rotation_angle,360)
        End Select
    Next
End Sub

Sub rotate_circle_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Cs As Integer, Ce As Integer)
    Dim As Integer i,j
    Dim As Double x1,y1,x2,y2,x1p,y1p,x2p,y2p
    Dim As Double arcangle,arcstart,arcend,arcendpoint1x,arcendpoint1y,arcendpoint2x,arcendpoint2y
    
    For i = Cs To Ce
        x1=circles(i,1)
        y1=circles(i,2)
        x1p=x1-pivot_pt_x
        y1p=y1-pivot_pt_y
        x1=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        y1=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        Select Case circles(i,0)
            Case 1
                circles(i,1)=x1
                circles(i,2)=y1
            Case 2
                arcendpoint1x=circles(i,1)+cos(circles(i,4))*circles(i,3)
                arcendpoint1y=circles(i,2)+sin(circles(i,4))*circles(i,3)
                arcendpoint2x=circles(i,1)+cos(circles(i,5))*circles(i,3)
                arcendpoint2y=circles(i,2)+sin(circles(i,5))*circles(i,3)
                x1p=arcendpoint1x-pivot_pt_x
                y1p=arcendpoint1y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcstart=arcangle*PI/180
                x1p=arcendpoint2x-pivot_pt_x
                y1p=arcendpoint2y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcend=arcangle*PI/180
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,4)=arcstart
                circles(i,5)=arcend
            Case 3,4'rotating ellipses
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,7)=mymod(circles(i,7)+rotation_angle,360)
        End Select
    Next
End Sub

Sub rotate_line_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Ls As Integer,Le As Integer)
    Dim As Integer i,j
    Dim As Double x1p,y1p,x2p,y2p
    
    for i = Ls to Le
        x1p=lines(i,1)-pivot_pt_x
        y1p=lines(i,2)-pivot_pt_y
        x2p=lines(i,3)-pivot_pt_x
        y2p=lines(i,4)-pivot_pt_y
        lines(i,1)=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,2)=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        lines(i,3)=x2p*cos(rotation_angle*pi/180) - y2p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,4)=y2p*cos(rotation_angle*pi/180) + x2p*sin(rotation_angle*pi/180)+pivot_pt_y
    Next
End Sub













Sub plotellipse(ex1 As Double,ey1 As Double,er1 As Double,estart As Double,eend As Double,er2 As Double,eangle As Double)
    '1x,2y,3z,4r,5color,6start,7end,8aspect,9=1(circle)2(arc)3(ellips)4(ellipticalarc),10group,11 is ellipse rotation , 12 block
    Dim As Double i,x1p,y1p
    Dim As Double eplotx,eploty,eplotxp,eplotyp,easpect,eresolution,elength
    Dim As BOOLEAN eplot
    If estart>eend Then
        elength=360+eend
    Else
        elength=eend
    EndIf
    eplot=FALSE
    eresolution=1
    'plotellipse
    For i = estart To elength Step eresolution
        eplotx=Cos(i*pi/180)*er1*Cos(eangle*pi/180) - Sin(i*pi/180)*er2*Sin(eangle*pi/180)+ex1
        eploty=Cos(i*pi/180)*er1*Sin(eangle*pi/180) + Sin(i*pi/180)*er2*Cos(eangle*pi/180)+ey1

        If eplot=false Then
            eplot=TRUE
        Else
            Line(eplotx,eploty)-(eplotxp,eplotyp)
        EndIf
        eplotxp=eplotx
        eplotyp=eploty
    Next

    x1p=Cos(eend*pi/180)*er1
    y1p=Sin(eend*pi/180)*er2
    eplotx=x1p*Cos(eangle*pi/180) - y1p*Sin(eangle*pi/180)+ex1
    eploty=y1p*Cos(eangle*pi/180) + x1p*Sin(eangle*pi/180)+ey1
    Line(eplotx,eploty)-(eplotxp,eplotyp)
End Sub

Sub read_entity_data()
    Dim As String entity_type
    Dim As Integer i,j,entity_count
    entity_type=""
    entity_count=0
    Do
        Read entity_type
        Read entity_count
        Select Case entity_type
            Case "ENTITY DATA START"
                'begin filling line and circle arrays
            Case "ENTITY DATA END"
                Exit Do
            Case "LINE"
                'Print "Line"
                linesc+=entity_count
                ReDim Preserve lines(linesc,4)
                For i = linesc-entity_count+1 To linesc
                    For j=1 To 4
                        Read lines(i,j)
                        'Print lines(i,j)
                    Next
                Next
            Case "CIRCLE"
                'Print "Circle"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=1
                    For j=1 To 3
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
            Case "ARC"
                'Print "Arc"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=2
                    For j=1 To 5
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
            Case "ELLIPSE"
                'Print "Ellipse"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=3
                    For j=1 To 7
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
        End Select
    Loop
End Sub

Sub zoominpan()
    Dim As Double panx,pany,panxf,panyf
    'viewsset=FALSE
    'mousexp=mousex-1
    'tempmousex=mousexp-1
    If wx2-wx1<=maxzoomin Then Exit Sub
    panxf=(mousex-wx1)/(wx2-wx1)
    panyf=(mousey-wy1)/(wy2-wy1)
    wx1=wx1+wzoom
    wy1=wy1+wzoom
    wx2=wx2-wzoom
    wy2=wy2-wzoom
    panx=wx1+int((wx2-wx1)*panxf)
    pany=wy1+Int((wy2-wy1)*panyf)
    wx1=wx1+(mousex-panx)
    wx2=wx2+(mousex-panx)
    wy1=wy1+(mousey-pany)
    wy2=wy2+(mousey-pany)
    'inview()
    'redraw
    wzoom=(wx2-wx1)/wzoomt
    If wzoom<20 Then wzoom=20
End Sub
Sub zoomoutpan()
    Dim As Double panx,pany,panxf,panyf
    'viewsset=FALSE
    'mousexp=mousex-1
    'tempmousex=mousexp-1
    ''If wx2-wx1>160000 Then Exit Sub --- what is the limit ???
    'If selentity=true and snapenable=true Then
    '    mousex=fxm
    '    mousey=fym
    'EndIf
    panxf=(mousex-wx1)/(wx2-wx1)
    panyf=(mousey-wy1)/(wy2-wy1)
    wx1=wx1-wzoom
    wy1=wy1-wzoom
    wx2=wx2+wzoom
    wy2=wy2+wzoom
    panx=wx1+Int((wx2-wx1)*panxf)
    pany=wy1+Int((wy2-wy1)*panyf)
    wx1=wx1+(mousex-panx)
    wx2=wx2+(mousex-panx)
    wy1=wy1+(mousey-pany)
    wy2=wy2+(mousey-pany)
    'inview()
    'redraw
    wzoom=(wx2-wx1)/wzoomt
End Sub





'big sprocket
Data "ENTITY DATA START"
DATA 0
'lines data x1,y1,x2,y2
DATA "LINE", 41
DATA-97.9202480392088, 6.072364661790445,-99.87901299359182, 13.03107389343951
DATA-95.00415385146233, 24.48385875660966,-99.01740943671227, 18.471024655737
DATA-95.00415385146239,-24.48385875660942,-99.01740943671233,-18.47102465573676
DATA-97.92024803920883,-6.072364661790189,-99.87901299359187,-13.03107389343926
DATA-82.7883911518724,-52.64343149083753,-88.46329194930918,-48.16505061641327
DATA-91.25122609839222,-36.03418271844164,-90.96376286065539,-43.25760013709514
DATA-62.46872390569825,-75.64989836238762,-69.24977108590986,-73.14434583711476
DATA-75.6498983623878,-62.46872390569804,-73.14434583711497,-69.24977108590967
DATA-36.03418271844185,-91.25122609839211,-43.25760013709537,-90.96376286065528
DATA-52.64343149083776,-82.78839115187229,-48.16505061641353,-88.46329194930904
DATA-6.07236466179045,-97.9202480392088,-13.03107389343952,-99.87901299359182
DATA-24.48385875660967,-95.00415385146231,-18.47102465573702,-99.01740943671227
DATA 24.48385875660942,-95.00415385146239, 18.47102465573675,-99.01740943671233
DATA 6.072364661790182,-97.92024803920883, 13.03107389343925,-99.87901299359184
DATA 52.64343149083753,-82.78839115187243, 48.16505061641328,-88.46329194930918
DATA 36.03418271844162,-91.25122609839225, 43.25760013709513,-90.96376286065542
DATA 75.64989836238763,-62.46872390569827, 73.14434583711477,-69.24977108590984
DATA 62.46872390569806,-75.64989836238782, 69.24977108590966,-73.14434583711496
DATA 91.25122609839212,-36.03418271844187, 90.96376286065529,-43.25760013709537
DATA 82.7883911518723,-52.64343149083776, 88.46329194930904,-48.16505061641352
DATA 97.92024803920879,-6.072364661790459, 99.8790129935918,-13.03107389343953
DATA 95.00415385146233,-24.48385875660968, 99.01740943671229,-18.47102465573703
DATA 95.00415385146238, 24.48385875660941, 99.01740943671233, 18.47102465573674
DATA 97.92024803920883, 6.072364661790175, 99.87901299359184, 13.03107389343924
DATA 82.78839115187243, 52.64343149083753, 88.46329194930915, 48.16505061641327
DATA 91.25122609839224, 36.03418271844164, 90.96376286065539, 43.25760013709511
DATA 62.46872390569824, 75.64989836238762, 69.24977108590984, 73.14434583711476
DATA 75.64989836238782, 62.46872390569804, 73.14434583711496, 69.24977108590964
DATA 36.03418271844188, 91.25122609839211, 43.25760013709538, 90.96376286065525
DATA 52.64343149083777, 82.78839115187229, 48.16505061641352, 88.46329194930904
DATA 6.072364661790466, 97.92024803920877, 13.03107389343953, 99.87901299359179
DATA 24.48385875660969, 95.00415385146233, 18.47102465573703, 99.01740943671227
DATA-24.48385875660939, 95.00415385146239,-18.47102465573673, 99.01740943671233
DATA-6.072364661790184, 97.92024803920883,-13.03107389343924, 99.87901299359184
DATA-52.64343149083752, 82.78839115187243,-48.16505061641326, 88.46329194930918
DATA-36.03418271844161, 91.25122609839225,-43.25760013709513, 90.96376286065542
DATA-75.64989836238765, 62.46872390569824,-73.14434583711476, 69.24977108590984
DATA-62.46872390569804, 75.64989836238782,-69.24977108590964, 73.14434583711496
DATA-91.25122609839211, 36.03418271844187,-90.96376286065525, 43.25760013709537
DATA-82.78839115187229, 52.64343149083778,-88.46329194930904, 48.16505061641352
DATA 0, 0, 3.3750779948604e-014, 95.88679832249493
'circles data x1,y1,radius
DATA "CIRCLE", 1
DATA 0, 0, 19.39421899515231
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 80
DATA-95.88679832249493, 1.4210854715e-014, 5.3851648071345, 4.839942021295272, 1.612405967231461
DATA-93.54028134689141, 14.8153251089273, 9.778725152391161, 4.247965142473813, 4.446394041093257
DATA-93.54028134689141, 14.8153251089273, 9.778725152391161, 1.522632000727353, 1.721060899346796
DATA-93.54028134689141, 14.8153251089273, 6.58506425852097, 2.553049150547038, 3.415976891273562
DATA-91.193764371288,-29.63065021785411, 5.3851648071345, 5.154101286654246, 1.92656523259044
DATA-93.54028134689149,-14.81532510892681, 9.778725152391161, 4.562124407832798, 4.760553306452237
DATA-93.54028134689149,-14.81532510892681, 9.778725152391161, 1.836791266086334, 2.035220164705774
DATA-93.54028134689149,-14.81532510892681, 6.58506425852097, 2.867208415906022, 3.73013615663255
DATA-77.5740493791016,-56.36084594350514, 5.3851648071345, 5.468260552013228, 2.240724497949415
DATA-84.38390687519488,-42.99574808067943, 9.778725152391161, 4.876283673191771, 5.074712571811213
DATA-84.38390687519488,-42.99574808067943, 9.778725152391161, 2.150950531445313, 2.349379430064753
DATA-84.38390687519488,-42.99574808067943, 6.58506425852097, 3.181367681264999, 4.044295421991523
DATA-56.3608459435052,-77.57404937910157, 5.3851648071345, 5.782419817372208, 2.554883763308393
DATA-66.96744766130357,-66.96744766130321, 9.778725152391161, 5.190442938550754, 5.388871837170198
DATA-66.96744766130357,-66.96744766130321, 9.778725152391161, 2.465109796804287, 2.663538695423732
DATA-66.96744766130357,-66.96744766130321, 6.58506425852097, 3.495526946623976, 4.358454687350502
DATA-29.63065021785415,-91.19376437128797, 5.3851648071345, 6.096579082731184, 2.869043028667383
DATA-42.99574808067986,-84.38390687519468, 9.778725152391161, 5.504602203909734, 5.703031102529175
DATA-42.99574808067986,-84.38390687519468, 9.778725152391161, 2.77926906216327, 2.97769796078271
DATA-42.99574808067986,-84.38390687519468, 6.58506425852097, 3.809686211982957, 4.672613952709483
DATA-1.953992523340276e-014,-95.88679832249493, 5.3851648071345, 0.1275530409105824, 3.183202294026359
DATA-14.8153251089273,-93.54028134689141, 9.778725152391161, 5.818761469268709, 6.01719036788815
DATA-14.8153251089273,-93.54028134689141, 9.778725152391161, 3.093428327522249, 3.291857226141691
DATA-14.8153251089273,-93.54028134689141, 6.58506425852097, 4.123845477341936, 4.986773218068459
DATA 29.6306502178541,-91.193764371288, 5.3851648071345, 0.4417123062695653, 3.497361559385338
DATA 14.81532510892682,-93.54028134689149, 9.778725152391161, 6.132920734627694, 0.04816432606754741
DATA 14.81532510892682,-93.54028134689149, 9.778725152391161, 3.40758759288123, 3.60601649150067
DATA 14.81532510892682,-93.54028134689149, 6.58506425852097, 4.438004742700917, 5.300932483427442
DATA 56.36084594350514,-77.57404937910162, 5.3851648071345, 0.7558715716285392, 3.811520824744314
DATA 42.99574808067943,-84.38390687519488, 9.778725152391161, 0.1638946928070797, 0.3623235914265215
DATA 42.99574808067943,-84.38390687519488, 9.778725152391161, 3.721746858240208, 3.920175756859651
DATA 42.99574808067943,-84.38390687519488, 6.58506425852097, 4.752164008059895, 5.615091748786417
DATA 77.57404937910158,-56.3608459435052, 5.3851648071345, 1.070030836987521, 4.125680090103296
DATA 66.96744766130321,-66.96744766130355, 9.778725152391161, 0.4780539581660643, 0.6764828567855078
DATA 66.96744766130321,-66.96744766130355, 9.778725152391161, 4.035906123599186, 4.234335022218629
DATA 66.96744766130321,-66.96744766130355, 6.58506425852097, 5.066323273418876, 5.929251014145397
DATA 91.19376437128798,-29.63065021785415, 5.3851648071345, 1.384190102346496, 4.439839355462276
DATA 84.38390687519468,-42.99574808067986, 9.778725152391161, 0.7922132235250471, 0.9906421221444854
DATA 84.38390687519468,-42.99574808067986, 9.778725152391161, 4.350065388958166, 4.548494287577609
DATA 84.38390687519468,-42.99574808067986, 6.58506425852097, 5.380482538777852, 6.24341027950438
DATA 95.88679832249491,-2.842170943040401e-014, 5.3851648071345, 1.698349367705476, 4.753998620821255
DATA 93.54028134689142,-14.81532510892731, 9.778725152391161, 1.106372488884023, 1.304801387503465
DATA 93.54028134689142,-14.81532510892731, 9.778725152391161, 4.664224654317144, 4.862653552936588
DATA 93.54028134689142,-14.81532510892731, 6.58506425852097, 5.694641804136832, 0.2743842376837707
DATA 91.193764371288, 29.63065021785411, 5.3851648071345, 2.012508633064455, 5.068157886180231
DATA 93.54028134689149, 14.81532510892681, 9.778725152391161, 1.420531754243002, 1.618960652862446
DATA 93.54028134689149, 14.81532510892681, 9.778725152391161, 4.978383919676126, 5.176812818295567
DATA 93.54028134689149, 14.81532510892681, 6.58506425852097, 6.008801069495812, 0.5885435030427483
DATA 77.57404937910161, 56.36084594350514, 5.3851648071345, 2.326667898423436, 5.38231715153921
DATA 84.3839068751949, 42.99574808067943, 9.778725152391161, 1.734691019601983, 1.933119918221423
DATA 84.3839068751949, 42.99574808067943, 9.778725152391161, 5.292543185035105, 5.490972083654545
DATA 84.3839068751949, 42.99574808067943, 6.58506425852097, 0.03977502767520338, 0.902702768401731
DATA 56.36084594350518, 77.57404937910157, 5.3851648071345, 2.640827163782412, 5.696476416898193
DATA 66.96744766130355, 66.96744766130321, 9.778725152391161, 2.048850284960963, 2.247279183580403
DATA 66.96744766130355, 66.96744766130321, 9.778725152391161, 5.606702450394082, 5.805131349013524
DATA 66.96744766130355, 66.96744766130321, 6.58506425852097, 0.3539342930341827, 1.216862033760707
DATA 29.63065021785415, 91.19376437128797, 5.3851648071345, 2.954986429141391, 6.010635682257174
DATA 42.99574808067987, 84.38390687519468, 9.778725152391161, 2.363009550319942, 2.561438448939382
DATA 42.99574808067987, 84.38390687519468, 9.778725152391161, 5.920861715753063, 6.119290614372505
DATA 42.99574808067987, 84.38390687519468, 6.58506425852097, 0.668093558393162, 1.53102129911969
DATA 3.3750779948604e-014, 95.88679832249493, 5.3851648071345, 3.269145694500375, 0.04160964043656391
DATA 14.81532510892732, 93.54028134689141, 9.778725152391161, 2.67716881567892, 2.875597714298361
DATA 14.81532510892732, 93.54028134689141, 9.778725152391161, 6.235020981112044, 0.1502645725518996
DATA 14.81532510892732, 93.54028134689141, 6.58506425852097, 0.982252823752143, 1.845180564478671
DATA-29.63065021785412, 91.193764371288, 5.3851648071345, 3.583304959859355, 0.3557689057955362
DATA-14.81532510892681, 93.54028134689149, 9.778725152391161, 2.991328081037897, 3.189756979657341
DATA-14.81532510892681, 93.54028134689149, 9.778725152391161, 0.2659949392914371, 0.4644238379108789
DATA-14.81532510892681, 93.54028134689149, 6.58506425852097, 1.296412089111122, 2.159339829837648
DATA-56.36084594350513, 77.5740493791016, 5.3851648071345, 3.897464225218333, 0.6699281711545243
DATA-42.99574808067943, 84.38390687519491, 9.778725152391161, 3.305487346396878, 3.50391624501632
DATA-42.99574808067943, 84.38390687519491, 9.778725152391161, 0.5801542046504129, 0.7785831032698581
DATA-42.99574808067943, 84.38390687519491, 6.58506425852097, 1.6105713544701, 2.473499095196629
DATA-77.57404937910157, 56.3608459435052, 5.3851648071345, 4.211623490577313, 0.9840874365135036
DATA-66.96744766130318, 66.96744766130355, 9.778725152391161, 3.619646611755859, 3.818075510375299
DATA-66.96744766130318, 66.96744766130355, 9.778725152391161, 0.8943134700093941, 1.092742368628841
DATA-66.96744766130318, 66.96744766130355, 6.58506425852097, 1.924730619829079, 2.787658360555602
DATA-91.19376437128797, 29.63065021785415, 5.3851648071345, 4.525782755936287, 1.298246701872485
DATA-84.38390687519468, 42.99574808067986, 9.778725152391161, 3.93380587711484, 4.132234775734278
DATA-84.38390687519468, 42.99574808067986, 9.778725152391161, 1.208472735368373, 1.406901633987815
DATA-84.38390687519468, 42.99574808067986, 6.58506425852097, 2.238889885188053, 3.101817625914583
DATA "ENTITY DATA END"
DATA 0

'small sprocket
Data "ENTITY DATA START"
DATA 0
'lines data x1,y1,x2,y2
DATA "LINE", 25
DATA-24.25747214638355, 54.51848019438589,-18.69707641887519, 59.13826305407355
DATA-6.251652986831032, 59.34312489724883,-13.37698837179155, 60.56377634995207
DATA-48.2668272075545, 35.08565275086517,-45.76127468228165, 41.86669993107675
DATA-35.08565275086495, 48.26682720755485,-41.86669993107654, 45.76127468228197
DATA-59.34312489724877, 6.251652986831377,-60.56377634995199, 13.37698837179189
DATA-54.51848019438584, 24.25747214638389,-59.13826305407347, 18.69707641887555
DATA-54.51848019438591,-24.25747214638349,-59.13826305407356,-18.69707641887513
DATA-59.34312489724884,-6.251652986830977,-60.56377634995209,-13.3769883717915
DATA-35.08565275086517,-48.2668272075545,-41.8666999310768,-45.76127468228166
DATA-48.26682720755475,-35.08565275086492,-45.76127468228192,-41.86669993107652
DATA-6.251652986831377,-59.34312489724877,-13.37698837179189,-60.56377634995199
DATA-24.25747214638389,-54.51848019438584,-18.69707641887555,-59.13826305407347
DATA 24.25747214638355,-54.51848019438589, 18.69707641887519,-59.13826305407355
DATA 6.251652986831032,-59.34312489724883, 13.37698837179155,-60.56377634995207
DATA 48.2668272075545,-35.08565275086517, 45.76127468228166,-41.8666999310768
DATA 35.08565275086492,-48.26682720755475, 41.86669993107652,-45.76127468228192
DATA 59.34312489724877,-6.251652986831377, 60.56377634995199,-13.37698837179189
DATA 54.51848019438584,-24.25747214638389, 59.13826305407347,-18.69707641887555
DATA 54.51848019438591, 24.25747214638349, 59.13826305407356, 18.69707641887513
DATA 59.34312489724884, 6.251652986830977, 60.56377634995209, 13.3769883717915
DATA 35.08565275086517, 48.2668272075545, 41.86669993107687, 45.76127468228167
DATA 48.26682720755475, 35.08565275086492, 45.76127468228187, 41.8666999310765
DATA 6.251652986831377, 59.34312489724877, 13.37698837179189, 60.56377634995199
DATA 24.25747214638389, 54.51848019438584, 18.69707641887555, 59.13826305407347
DATA 0, 0, 5.87446757904786e-014, 57.95554957734412
'circles data x1,y1,radius
DATA "CIRCLE", 1
DATA 0, 0, 11.01923788646684
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 48
DATA-28.97777478867205, 50.19097822426848, 5.3851648071345, 3.688024714979013, 0.460488660915196
DATA-14.48888739433575, 54.07326390080636, 9.778725152391161, 3.096047836157557, 3.294476734777001
DATA-14.48888739433575, 54.07326390080636, 9.778725152391161, 0.3707146944110952, 0.5691435930305386
DATA-14.48888739433575, 54.07326390080636, 6.58506425852097, 1.401131844230782, 2.264059584957308
DATA-50.19097822426848, 28.97777478867205, 5.3851648071345, 4.211623490577305, 0.984087436513495
DATA-39.5843765064701, 39.58437650647054, 9.778725152391161, 3.619646611755854, 3.818075510375299
DATA-39.5843765064701, 39.58437650647054, 9.778725152391161, 0.8943134700093941, 1.092742368628841
DATA-39.5843765064701, 39.58437650647054, 6.58506425852097, 1.924730619829083, 2.787658360555608
DATA-57.95554957734413, 1.067878424576563e-013, 5.3851648071345, 4.735222266175607, 1.507686212111794
DATA-54.07326390080625, 14.48888739433632, 9.778725152391161, 4.143245387354153, 4.3416742859736
DATA-54.07326390080625, 14.48888739433632, 9.778725152391161, 1.417912245607691, 1.616341144227137
DATA-54.07326390080625, 14.48888739433632, 6.58506425852097, 2.44832939542738, 3.311257136153909
DATA-50.19097822426853,-28.97777478867207, 5.3851648071345, 5.258821041773906, 2.031284987710093
DATA-54.07326390080643,-14.48888739433571, 9.778725152391161, 4.666844162952454, 4.865273061571899
DATA-54.07326390080643,-14.48888739433571, 9.778725152391161, 1.941511021205992, 2.139939919825437
DATA-54.07326390080643,-14.48888739433571, 6.58506425852097, 2.97192817102568, 3.834855911752206
DATA-28.9777747886721,-50.19097822426849, 5.3851648071345, 5.782419817372201, 2.554883763308391
DATA-39.58437650647054,-39.5843765064701, 9.778725152391161, 5.19044293855075, 5.388871837170198
DATA-39.58437650647054,-39.5843765064701, 9.778725152391161, 2.465109796804289, 2.663538695423734
DATA-39.58437650647054,-39.5843765064701, 6.58506425852097, 3.495526946623978, 4.358454687350507
DATA-5.87446757904786e-014,-57.95554957734412, 5.3851648071345, 0.02283328579091916, 3.07848253890669
DATA-14.48888739433632,-54.07326390080625, 9.778725152391161, 5.714041714149051, 5.912470612768496
DATA-14.48888739433632,-54.07326390080625, 9.778725152391161, 2.988708572402589, 3.187137471022033
DATA-14.48888739433632,-54.07326390080625, 6.58506425852097, 4.019125722222277, 4.882053462948803
DATA 28.97777478867207,-50.19097822426853, 5.3851648071345, 0.5464320613892163, 3.602081314504988
DATA 14.48888739433576,-54.07326390080642, 9.778725152391161, 6.23764048974735, 0.1528840811872107
DATA 14.48888739433576,-54.07326390080642, 9.778725152391161, 3.512307348000888, 3.710736246620333
DATA 14.48888739433576,-54.07326390080642, 6.58506425852097, 4.542724497820575, 5.405652238547104
DATA 50.19097822426849,-28.9777747886721, 5.3851648071345, 1.070030836987512, 4.125680090103288
DATA 39.5843765064701,-39.58437650647054, 9.778725152391161, 0.4780539581660626, 0.6764828567855078
DATA 39.5843765064701,-39.58437650647054, 9.778725152391161, 4.035906123599186, 4.234335022218632
DATA 39.5843765064701,-39.58437650647054, 6.58506425852097, 5.066323273418876, 5.929251014145402
DATA 57.95554957734413,-1.067878424576563e-013, 5.3851648071345, 1.593629612585816, 4.649278865701581
DATA 54.07326390080625,-14.48888739433632, 9.778725152391161, 1.001652733764362, 1.200081632383808
DATA 54.07326390080625,-14.48888739433632, 9.778725152391161, 4.559504899197487, 4.757933797816929
DATA 54.07326390080625,-14.48888739433632, 6.58506425852097, 5.589922049017172, 0.1696644825641127
DATA 50.19097822426858, 28.97777478867208, 5.3851648071345, 2.117228388184113, 5.172877641299886
DATA 54.07326390080648, 14.48888739433572, 9.778725152391161, 1.52525150936266, 1.723680407982106
DATA 54.07326390080648, 14.48888739433572, 9.778725152391161, 5.083103674795785, 5.28153257341523
DATA 54.07326390080648, 14.48888739433572, 6.58506425852097, 6.113520824615471, 0.6932632581624133
DATA 28.97777478867215, 50.19097822426851, 5.3851648071345, 2.640827163782413, 5.696476416898179
DATA 39.58437650647056, 39.58437650647005, 9.778725152391161, 2.048850284960961, 2.247279183580404
DATA 39.58437650647056, 39.58437650647005, 9.778725152391161, 5.606702450394082, 5.80513134901353
DATA 39.58437650647056, 39.58437650647005, 6.58506425852097, 0.3539342930341862, 1.216862033760712
DATA 5.87446757904786e-014, 57.95554957734412, 5.3851648071345, 3.164425939380712, 6.220075192496474
DATA 14.48888739433632, 54.07326390080625, 9.778725152391161, 2.572449060559258, 2.770877959178705
DATA 14.48888739433632, 54.07326390080625, 9.778725152391161, 6.130301225992383, 0.04554481743223981
DATA 14.48888739433632, 54.07326390080625, 6.58506425852097, 0.8775330686324797, 1.740460809359009
DATA "ENTITY DATA END"
DATA 0


'chain piece 1
Data "ENTITY DATA START"
DATA 0
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 8
DATA 15, 9.42809041582052, 7.716909687891069, 3.702733079760211, 5.722044881009169
DATA 15,-9.428090415820577, 7.716909687891069, 0.5611404261704176, 2.580452227419375
DATA 0, 0, 9.999999999999982, 0.5611404261704158, 1.570796326794897
DATA 0, 0, 9.999999999999982, 4.71238898038469, 5.72204488100917
DATA 0, 0, 5.385164807134504, 4.71238898038469, 1.570796326794897
DATA 30, 0, 5.385164807134504, 1.570796326794897, 4.71238898038469
DATA 30, 0, 9.999999999999982, 1.570796326794897, 2.580452227419377
DATA 30, 0, 9.999999999999982, 3.702733079760208, 4.712388980384688
DATA "ENTITY DATA END"
DATA 0

'chain piece 2
Data "ENTITY DATA START"
DATA 0
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 6
DATA 15, 9.428090415820492, 7.716909687891069, 3.702733079760211, 5.722044881009169
DATA 15,-9.428090415820606, 7.716909687891069, 0.5611404261704176, 2.580452227419375
DATA 0, 0, 5.385164807134504, 4.71238898038469, 1.570796326794897
DATA 30, 0, 9.999999999999982, 1.570796326794897, 4.71238898038469
DATA 30, 0, 5.385164807134504, 1.570796326794897, 4.71238898038469
DATA 0, 0, 9.999999999999982, 4.71238898038469, 7.853981633974483
DATA "ENTITY DATA END"
DATA 0



'chain piece 3
Data "ENTITY DATA START"
DATA 0
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 4
DATA 30.00000000000001, 0, 9.999999999999982, 0.5611404261704158, 2.580452227419379
DATA 30.00000000000001, 0, 9.999999999999982, 3.702733079760208, 5.72204488100917
DATA-5.329070518200751e-015, 0, 9.999999999999982, 0.5611404261704158, 2.580452227419379
DATA-5.329070518200751e-015, 0, 9.999999999999982, 3.702733079760208, 5.72204488100917
DATA "ENTITY DATA END"
DATA 0
Last edited by owen on Oct 10, 2017 16:55, edited 1 time in total.
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: FB CAD

Post by owen »

This project started back in 2007 as I was inspired by a fella out of Johannesburg South Africa. His name was Dennis Waites.
Imagine that. Dennis (belated), who I met on skpye (while driving a big rig - 80 thousand pounds barrelling down the road) inspired me to create fbcadcam (aka fbcad).

Mr. Waites was an engineer working for the mining industry as a cad (draftsman). He designed HUGE conveyor belts to haul the ore out of the mine. Dennis mentioned to me he had written custom LISP routines to automate some autocad work he was doing. There were 2 LISP routines he was partial to: His "Copy Rotate" and "Rectangle In Rectangle" routines (macros).

Being confident in my ability (at the time), I told Dennis I could make my own cad program and I would write it in FreeBasic. And because it would all be FreeBasic, I wouldn't have to depend on the idea of writing macros in LISP.

The idea of creating a cad program (from scratch) was daunting in itself.
The idea of creating a programming language to use as an interpreter for the cad program's macro system was even more so.

Though I can not share my finished works with Dennis, the idea of creativity lives on within this community.
fbcadcam (aka fbcad) is my contribution to FreeBasic. It serves as an example of appreciation. And I thank those who wrote this compiler.
Good job everyone. BE EXCELENT.
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: FB CAD

Post by owen »

My goal is to inspire people to code in freebasic so I opened an office in the PI for this project.
Image
Image
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

Re: FB CAD

Post by dafhi »

hi owen. i've been thinking about you
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: FB CAD

Post by owen »

hi dafhi how are you?
i see you have solid object topic.
so what u been thinking about me for?
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: FB CAD

Post by paul doe »

owen wrote:My goal is to inspire people to code in freebasic so I opened an office in the PI for this project.
Hi owen, long time no see!

Well, that's a serious undertaking. I wish you the best of luck, and congratulations!
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

Re: FB CAD

Post by dafhi »

i have a good memory :-) wondering how you are doing
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: FB CAD

Post by owen »

yes long time no talk
hello dafhi and paul you guys are doing a great job with 3d stuff.
i am doing fine. had some serious teeth issues going on but the lord said it was ok to get them pulled so i did.
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

Re: FB CAD

Post by dafhi »

you seem like a very positive guy.

[edit] .. to answer your question, how am i doing .. atm it's a tad rough. i get hit with these odd 'energy waves' which knock me about and obliterate my sense of direction. also my own energy can be extremely difficult to deal with
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: FB CAD

Post by owen »

dafhi north is up unless u b down under.
...
Using FLTK for fbcadcam's GUI. unzip and find better_Fl_Pack_HV4.bas which is an example of using FLTK's horizontal and vertical packs.
note: this is just the beginnings of the GUI. No fbcadcam functionality is tied into the app yet.
files for the fltk implimentation are at fbcadcam.com/fltk
http://fbcadcam.com/fltk/fbcadcam-fltk- ... -c-1.3.zip
Image
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: FB CAD

Post by owen »

tool expander example
Image
Post Reply