dim swApp
dim storePath
dim sw2003api
Private Type BROWSEINFO
   hwndOwner       As Long
   pIDLRoot        As Long
   pszDisplayName  As Long
   lpszTitle       As String
   ulFlags         As Long
   lpfnCallback    As Long
   lParam          As Long
  iImage          As Long
End Type
Private Declare Function SHBrowseForFolder Lib "Shell32" (lpbi As BROWSEINFO) As Long
Private Declare Function SHGetPathFromIDList Lib "Shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Declare Sub CoTaskMemFree Lib "ole32" (ByVal hMem As Long)
Private Const MAX_PATH = 260
'Directories only
Private Const BIF_RETURNONLYFSDIRS = &H1&
'Windows 2000 (Shell32.dll 5.0) extended dialog
Private Const BIF_NEWDIALOGSTYLE = &H40
' show edit box
Private Const BIF_EDITBOX = &H10&
Function getFeatureByTypeOcc(model, typ, nr)  
  Set feat = model.FirstFeature ' Get the 1st feature in part
  Set res = Nothing
  Count = 0
  Do While Not feat Is Nothing ' While we have a valid feature
    If feat.GetTypeName() = typ Then
      Count = Count + 1
      If Count = nr Then
        Set res = feat
        Exit Do
      End If
    End If
    Set feat = feat.GetNextFeature() ' Get the next feature
  Loop ' Continue until no more
  Set getFeatureByTypeOcc = res
End Function
Function getLastFeatureByType(model,typ)  
  Set feat = model.FirstFeature ' Get the 1st feature in part
  Set res = Nothing
  Count = 0
  Do While Not feat Is Nothing ' While we have a valid feature
    If feat.GetTypeName() = typ Then
      Set res = feat
    End If
    Set feat = feat.GetNextFeature() ' Get the next feature
  Loop ' Continue until no more
  Set getLastFeatureByType = res
End Function
' this code with copy a matrix to a other
Function copyMat4x4(source)
Dim res(0 To 15) As Double
For i = 0 To 15
 res(i) = source(i)
Next
copyMat4x4 = res
End Function

' This code creates a mat from a sw mat
Function createMatFromSWMat(source)
 Dim res(0 To 15) As Double
 res(0) = source(0)
 res(1) = source(1)
 res(2) = source(2)
 res(3) = 0
 res(4) = source(3)
 res(5) = source(4)
 res(6) = source(5)
 res(7) = 0
 res(8) = source(6)
 res(9) = source(7)
 res(10) = source(8)
 res(11) = 0
 res(12) = source(9)
 res(13) = source(10)
 res(14) = source(11)
 res(15) = source(12)
 createMatFromSWMat = res
End Function
Function createSWMatFromMat(source)
 Dim res(0 To 15) As Double
 res(0) = source(0)
 res(1) = source(1)
 res(2) = source(2)
 res(3) = source(4)
 res(4) = source(5)
 res(5) = source(6)
 res(6) = source(8)
 res(7) = source(9)
 res(8) = source(10)
 res(9) = source(12)
 res(10) = source(13)
 res(11) = source(14)
 res(12) = source(15)
 res(13) = 0
 res(14) = 0
 res(15) = 0
 createSWMatFromMat = res
End Function
Function createMat4x4FromValues(x1,x2,x3,y1,y2,y3,z1,z2,z3,t1,t2,t3)
 Dim res(0 To 15) As Double
 res(0) = x1
 res(1) = x2
 res(2) = x3
 res(3) = 0
 res(4) = y1
 res(5) = y2
 res(6) = y3
 res(7) = 0
 res(8) = z1
 res(9) = z2
 res(10) =z3
 res(11) = 0
 res(12) = t1
 res(13) = t2
 res(14) = t3
 res(15) = 1
 createMat4x4FromValues = res
End Function
' this code will mult a common mat with any other stuff
Function multMatMat(ld, xld, yld, rd, xrd, yrd)
  mulRes = yld * xrd
  'Dim od(0 To 0) As Variant
  ReDim od(mulRes - 1) As Double
  For i = 0 To mulRes - 1
   od(i) = 0#
  Next
  y = 0
  While y < yld
    x = 0
    While x < xrd
      i = 0
      While i < xld
       od(x * yld + y) = od(x * yld + y) + ld(i * yld + y) * rd(x * yrd + i)
       i = i + 1
      Wend
      x = x + 1
    Wend
    y = y + 1
  Wend
  multMatMat = od

End Function
' this code will mult a vector with a matrix
Function mulMat4x4Values3d(mat, x,y,z)
  tmp = createVec4d(x, y, z, 1)
  res = multMatMat(mat, 4, 4, tmp, 1, 3)
  mulMat4x4Values3d = createVec3d(res(0), res(1), res(2))
End Function
Function mulMat4x4Vec3d(mat, vec)
  tmp = createVec4d(vec(0), vec(1), vec(2), 1)
  res = multMatMat(mat, 4, 4, tmp, 1, 3)
  mulMat4x4Vec3d = createVec3d(res(0), res(1), res(2))
End Function
Function mulMat4x4Mat4x4(mat1, mat2)
  mulMat4x4Mat4x4 = multMatMat(mat1, 4, 4, mat2, 4, 4)
End Function
' create a 4x4 matrix
Function createMat4x4()
 Dim res(0 To 15) As Double
 for i = 0 to 15 
 res(i) = 0
 next
 createMat4x4 = res
End Function
Function createMat4x4Ident()
 Dim res(0 To 15) As Double
 res(0) = 1
 res(5) = 1
 res(10) = 1
 res(15) = 1
 res(1) = 0
 res(2) = 0
 res(3) = 0
 res(4) = 0
 res(6) = 0
 res(7) = 0
 res(8) = 0
 res(9) = 0
 res(11) = 0
 res(12) = 0
 res(13) = 0
 res(14) = 0
 createMat4x4Ident = res
End Function
' this function create a new vector
Function createVec3d(x, y, z)
 Dim res(0 To 2) As Double
 res(0) = x
 res(1) = y
 res(2) = z
 createVec3d = res
End Function
' this function create a new vector
Function createVec4d(x, y, z, w)
 Dim res(0 To 3) As Double
 res(0) = x
 res(1) = y
 res(2) = z
 res(3) = w
 createVec4d = res
End Function

Function getMatTVec(mat)
 getMatTVec = createVec3d(mat(12), mat(13), mat(14))
End Function

Sub setMatTVec(mat, v)
 mat(12) = v(0)
 mat(13) = v(1)
 mat(14) = v(2)
End Sub
Sub setMatXVec(mat, v)
 mat(0) = v(0)
 mat(1) = v(1)
 mat(2) = v(2)
End Sub
Sub setMatYVec(mat, v)
 mat(4) = v(0)
 mat(5) = v(1)
 mat(6) = v(2)
End Sub
Sub setMatZVec(mat, v)
 mat(8) = v(0)
 mat(9) = v(1)
 mat(10) = v(2)
End Sub
Sub setMatScale(mat, s)
 mat(15) = s
End Sub
Function getMatXVec(mat)
 getMatXVec = createVec3d(mat(0), mat(1), mat(2))
End Function
Function getMatYVec(mat)
 getMatYVec = createVec3d(mat(4), mat(5), mat(6))
End Function
Function getMatZVec(mat)
 getMatZVec = createVec3d(mat(8), mat(9), mat(10))
End Function

Function negVec3d(v)
 negVec3d = createVec3d(-v(0), -v(1), -v(2))
End Function
Function scaleVec3d(v,s)
 scaleVec3d = createVec3d(v(0)*s,v(1)*s,v(2)*s)
End Function
' invert a 4x4 matrix
Function invMat4x4(source)
target = copyMat4x4(source)
setMatTVec target, createVec3d(0, 0, 0)
 target(1) = source(4)
 target(4) = source(1)
 target(2) = source(8)
 target(8) = source(2)
 target(6) = source(9)
 target(9) = source(6)
 setMatScale target,1
 t = getMatTVec(source)
 v = mulMat4x4Vec3d(target, t)
 setMatTVec target, negVec3d(v)
 invMat4x4 = target
End Function
Function getFaceFromModel(part, pos, normal)
 Dim partBodies As Variant
 partBodies = part.GetBodies(swSolidBody)
 For k = LBound(partBodies) To UBound(partBodies)
   found = 0
   Dim body As Object
   Set body = partBodies(k)
   Set face = body.GetFirstFace()
   getFaceFromModel = noting
   Do While Not face Is Nothing ' While we have a valid feature
     Set sur = face.GetSurface()
     If sur.IsPlane() Then
       planePara = sur.PlaneParams
       faceNormal = face.normal
       nTest = faceNormal(0) * normal(0) + faceNormal(1) * normal(1) + faceNormal(2) * normal(2)
       If nTest > 1 - 0.000001 Then
         ' check projection
         closeRes = face.GetClosestPointOn(pos(0), pos(1), pos(2))
         dTest = (pos(0) - closeRes(0)) * (pos(0) - closeRes(0)) + (pos(1) - closeRes(1)) * (pos(1) - closeRes(1)) + (pos(2) - closeRes(2)) * (pos(2) - closeRes(2))
         If dTest < 0.000001 Then
           Set getFaceFromModel = face
           found=1
           Exit Do
         End If
       End If
     else
       If sur.IsCylinder() then
         closeRes = face.GetClosestPointOn(pos(0), pos(1), pos(2))
         dTest = (pos(0) - closeRes(0)) * (pos(0) - closeRes(0)) + (pos(1) - closeRes(1)) * (pos(1) - closeRes(1)) + (pos(2) - closeRes(2)) * (pos(2) - closeRes(2))
         If dTest < 0.00000001 Then
           res=sur.EvaluateAtPoint(closeRes(0),closeRes(1),closeRes(2))
           nTest=res(0)*normal(0)+res(1)*normal(1)+res(2)*normal(2)
           if nTest>1-0.00000001 then
             Set getFaceFromModel = face
             found=1
             Exit Do
           End if
         End if
       End if
     End if
     Set face = face.GetNextFace ' Get the next Face
   Loop
   If (found = 1) Then
     Exit For
   End If
 Next k
End Function
Function getEdgeFromModel(part, pos,byref edgeRet)
 Dim partBodies As Variant
 partBodies = part.GetBodies(swSolidBody)
 For k = LBound(partBodies) To UBound(partBodies)
   Dim body As Object
   Set body = partBodies(k)
   edges= body.GetEdges()
   start= LBound(edges)
   ende = UBound(edges)
   For i = start To ende
     Set edge = edges(i)
     closeRes=edge.GetClosestPointOn(pos(0),pos(1),pos(2))
     dTest = (pos(0) - closeRes(0)) * (pos(0) - closeRes(0)) + (pos(1) - closeRes(1)) * (pos(1) - closeRes(1)) + (pos(2) - closeRes(2)) * (pos(2) - closeRes(2))
     If dTest < 0.00000001 Then
       set edgeRet=edge
       getEdgeFromModel=true
       exit function
     End If
   Next i
 Next k
 getEdgeFromModel=false
End Function
sub cLn(part,wMat,x1,y1,x2,y2)
pk1=mulMat4x4Values3d(wMat,x1,y1,0)
pk2=mulMat4x4Values3d(wMat,x2,y2,0)
Part.CreateLine2 pk1(0),pk1(1),0,pk2(0),pk2(1),0
end sub
sub cCLn(part,wMat,x1,y1,x2,y2)
pk1=mulMat4x4Values3d(wMat,x1,y1,0)
pk2=mulMat4x4Values3d(wMat,x2,y2,0)
Part.CreateCenterLineVB pk1(0),pk1(1),0,pk2(0),pk2(1),0
end sub
sub cArc(part,wMat,x1,y1,x2,y2,x3,y3)
pk1=mulMat4x4Values3d(wMat,x1,y1,0)
pk2=mulMat4x4Values3d(wMat,x2,y2,0)
pk3=mulMat4x4Values3d(wMat,x3,y3,0)
Part.Create3PointArc pk1(0),pk1(1),0,pk3(0),pk3(1),0,pk2(0),pk2(1),0
end sub
sub cCir(part,wMat,x1,y1,rad)
pk1=mulMat4x4Values3d(wMat,x1,y1,0)
Part.CreateCircleByRadius2 pk1(0),pk1(1),0,rad
end sub
Public Function BrowseForFolder() As String
  Dim tBI         As BROWSEINFO
  Dim lngPIDL     As Long
  Dim strPath     As String
  With tBI
    .lpszTitle = ""
    .ulFlags = BIF_RETURNONLYFSDIRS Or BIF_NEWDIALOGSTYLE Or BIF_EDITBOX
  End With
  lngPIDL = SHBrowseForFolder(tBI)
  If (lngPIDL <> 0) Then
    ' get path from ID list
    strPath = Space$(MAX_PATH)
    SHGetPathFromIDList lngPIDL, strPath
    strPath = Left$(strPath, InStr(strPath, Chr$(0)) - 1)
    ' release list
    CoTaskMemFree lngPIDL
  End If
  BrowseForFolder = strPath
End Function
Sub CreatePart0
dim error as long
set res=swApp.OpenDoc2 ( storePath & "TP37L8W12_16.sldprt",1,true,false,true,error)
if not res is nothing then
 exit sub
end if
set part=swApp.NewPart
part.SetAddToDB(true)
part.SetDisplayWhenAdded (false)
part.SetUnits 3,2,64,5,false
swSumInfoTitleVar = 0
swSumInfoAuthorVar = 2
Set swModel = swApp.ActiveDoc
swModel.AddCustomInfo3 "", "NB", 30, "TP37L8W12-16
swModel.AddCustomInfo3 "", "NN", 30, "TP37L6
swModel.AddCustomInfo3 "", "NT", 30, "Timing Pulleys - 3/8' Pitch (L)
swModel.AddCustomInfo3 "", "NBSYN", 30, "$PN.
swModel.AddCustomInfo3 "", "LINA", 30, "TP37L8W12-16
swModel.AddCustomInfo3 "", "PN", 30, "TP37L8W12-16
swModel.AddCustomInfo3 "", "DES", 30, "Max-M-Drive Timing Serie, Double Flange
swModel.AddCustomInfo3 "", "CN", 30, "Master Inch/Metric Catalog
swModel.AddCustomInfo3 "", "CP", 30, "A137
swModel.AddCustomInfo3 "", "P", 30, "3/8
swModel.AddCustomInfo3 "", "N", 30, "16
swModel.AddCustomInfo3 "", "FBW", 30, "3/4”
swModel.AddCustomInfo3 "", "OD", 30, "1.880
swModel.AddCustomInfo3 "", "PD", 30, "1.910
swModel.AddCustomInfo3 "", "FD", 30, "2.12
swModel.AddCustomInfo3 "", "B", 30, "1/2”
swModel.AddCustomInfo3 "", "B1", 30, "0.5000
swModel.AddCustomInfo3 "", "W", 30, "13/16”
swModel.AddCustomInfo3 "", "W1", 30, "0.8125
swModel.AddCustomInfo3 "", "L", 30, "1.46
swModel.AddCustomInfo3 "", "H", 30, "1-1/8”
swModel.AddCustomInfo3 "", "H1", 30, "1.1250
swModel.AddCustomInfo3 "", "A1", 30, "0.0750
swModel.AddCustomInfo3 "", "A2", 30, "0.1280
swModel.AddCustomInfo3 "", "PSTOL", 30, "0.0010
swModel.AddCustomInfo3 "", "TYP", 30, "2.0000
swModel.AddCustomInfo3 "", "KT", 30, "2
swModel.AddCustomInfo3 "", "CreationOption_UseAsmMates", 30, "0
swModel.AddCustomInfo3 "", "SUPPLIER", 30, "W.M.Berg
swModel.AddCustomInfo3 "", "ARTICLENO", 30, "TP37L8W12-16
swModel.AddCustomInfo3 "", "BOMINFO", 30, "TP37L8W12-16
swModel.AddCustomInfo3 "", "CREATOR", 30, "CADENAS GmbH
swModel.SummaryInfo (swSumInfoAuthorVar)="W.M.Berg"
swModel.SummaryInfo (swSumInfoTitleVar)="TP37L8W12-16"
valRGB=part.MaterialPropertyValues
valRGB(0)=0.68999999761581
valRGB(1)=0.68999999761581
valRGB(2)=0.68999999761581
part.MaterialPropertyValues=valRGB
Dim featMgr as object
if (sw2003api=1) then
  set featMgr=part.FeatureManager
End If
part.CreatePlaneFixed createVec3d(0,0,0),createVec3d(0,0,-1),createVec3d(0,1,0),1
part.BlankRefGeom
set feat4=getLastFeatureByType(part,"RefPlane")
feat4.select false
codeBag0 part
set feat4=getLastFeatureByType(part,"ProfileFeature")
feat4.select false
if (sw2003api=0) then
  part.FeatureRevolve2 6.2831853071796,1,6.2831853071796,0,0
else
  featMgr.FeatureRevolve 6.2831853071796,1,6.2831853071796,0,0,1,1,1
end if
part.CreatePlaneFixed createVec3d(0,0,0),createVec3d(1,0,0),createVec3d(0,1,0),1
part.BlankRefGeom
set feat6=getLastFeatureByType(part,"RefPlane")
feat6.select false
codeBag1 part
set feat6=getLastFeatureByType(part,"ProfileFeature")
feat6.select false
if (sw2003api=0) then
  part.FeatureCut 0,0,0,0,0,0.0206375,0.0206375,1,1,0,0,0,0,0,0
else
  featMgr.FeatureCut 0,0,0,0,0,0.0206375,0.0206375,1,1,0,0,0,0,0,0,0,0,0,1,1
end if
part.CreatePlaneFixed createVec3d(0,0,-2.54e-005),createVec3d(1,0,-2.54e-005),createVec3d(0,1,-2.54e-005),1
part.BlankRefGeom
set feat9=getLastFeatureByType(part,"RefPlane")
feat9.select false
codeBag2 part
set feat9=getLastFeatureByType(part,"ProfileFeature")
feat9.select false
if (sw2003api=0) then
  part.FeatureExtrusion 1,0,1,0,0,0.001905,0.001905,1,1,0,0,0,0,0,0
else
  featMgr.FeatureExtrusion 1,0,1,0,0,0.001905,0.001905,1,1,0,0,0,0,0,0,0,0,1,1,1
end if
part.CreatePlaneFixed createVec3d(0,0,0),createVec3d(0,0,-1),createVec3d(0,1,0),1
part.BlankRefGeom
set feat11=getLastFeatureByType(part,"RefPlane")
feat11.select false
codeBag3 part
set feat11=getLastFeatureByType(part,"ProfileFeature")
feat11.select false
if (sw2003api=0) then
  part.FeatureRevolveCut2 6.2831853071796,1,6.2831853071796,0,0
else
  featMgr.FeatureRevolveCut 6.2831853071796,1,6.2831853071796,0,0,1,1
end if
part.SetDisplayWhenAdded (true)
part.SetAddToDB(false)
part.SaveAs2 storePath & "TP37L8W12_16.sldprt",0,0,false
End Sub
sub codeBag0(part)
Part.InsertSketch
Set swActiveMat = Part.GetActiveSketch()
swSketchMat= createMatFromSWMat(swActiveMat.ModelToSketchXForm)
mSkMat=createMat4x4FromValues(0,0,-1,0,1,0,1,0,0,0,0,0)
wMat=mulMat4x4Mat4x4(swSketchMat,mSkMat)
cLn part,wMat,-0.035179,0,-0.035179,0.013440833333333
cLn part,wMat,-0.035179,0.013440833333333,-0.034332333333333,0.0142875
cLn part,wMat,-0.034332333333333,0.0142875,-0.01279525,0.0142875
cArc part,wMat,-0.01279525,0.0142875,-0.012503391676065,0.014408391676065,-0.0123825,0.01470025
cLn part,wMat,-0.0123825,0.01470025,-0.0123825,0.01965325
cArc part,wMat,-0.0123825,0.01965325,-0.012503391676065,0.019945108323935,-0.01279525,0.020066
cLn part,wMat,-0.01279525,0.020066,-0.0225425,0.020066
cLn part,wMat,-0.0225425,0.020066,-0.0225425,0.026924
cLn part,wMat,-0.0225425,0.026924,-0.0206121,0.026924
cLn part,wMat,-0.0206121,0.026924,-0.0206121,0.031834666666667
cLn part,wMat,-0.0206121,0.031834666666667,0,0.031834666666667
cLn part,wMat,0,0.031834666666667,0,0.020066
cLn part,wMat,0,0.020066,-0.00784225,0.020066
cArc part,wMat,-0.00784225,0.020066,-0.0081341083239347,0.019945108323935,-0.008255,0.01965325
cLn part,wMat,-0.008255,0.01965325,-0.008255,0.01470025
cArc part,wMat,-0.008255,0.01470025,-0.0081341083239347,0.014408391676065,-0.00784225,0.0142875
cLn part,wMat,-0.00784225,0.0142875,0.0010583333333333,0.0142875
cLn part,wMat,0.0010583333333333,0.0142875,0.001905,0.013440833333333
cLn part,wMat,0.001905,0.013440833333333,0.001905,0
cLn part,wMat,0.001905,0,-0.035179,0
cCLn part,wMat,0.001905,0,-0.035179,0
Part.InsertSketch
end sub

sub codeBag1(part)
Part.InsertSketch
Set swActiveMat = Part.GetActiveSketch()
swSketchMat= createMatFromSWMat(swActiveMat.ModelToSketchXForm)
mSkMat=createMat4x4FromValues(1,0,0,0,1,0,0,0,1,0,0,0)
wMat=mulMat4x4Mat4x4(swSketchMat,mSkMat)
cCir part,wMat,0,0,0.047752
cArc part,wMat,-0.023791536918834,0.0020065261124034,-0.023876,2.9238701303863e-018,-0.023791536918834,-0.0020065261124034
cLn part,wMat,-0.023791536918834,-0.0020065261124034,-0.021806909007563,-0.0026802165091436
cArc part,wMat,-0.021806909007563,-0.0026802165091436,-0.021692740710711,-0.0034856622696233,-0.021548833395739,-0.0042863294650164
cArc part,wMat,-0.021548833395739,-0.0042863294650164,-0.021375384348105,-0.0050811204444289,-0.021172631352624,-0.0058689456127906
cLn part,wMat,-0.021172631352624,-0.0058689456127906,-0.022748378306122,-0.0072508386026412
cArc part,wMat,-0.022748378306122,-0.0072508386026412,-0.022058547718239,-0.0091369496311489,-0.021212649706473,-0.010958415416039
cLn part,wMat,-0.021212649706473,-0.010958415416039,-0.019121282446222,-0.010821339963784
cArc part,wMat,-0.019121282446222,-0.010821339963784,-0.018707573945295,-0.011521784500732,-0.018268218851899,-0.012206433589674
cArc part,wMat,-0.018268218851899,-0.012206433589674,-0.017803819486842,-0.012874348631288,-0.017315012504629,-0.013524613967302
cLn part,wMat,-0.017315012504629,-0.013524613967302,-0.018241985310866,-0.015404328869449
cArc part,wMat,-0.018241985310866,-0.015404328869449,-0.01688288150761,-0.01688288150761,-0.015404328869449,-0.018241985310866
cLn part,wMat,-0.015404328869449,-0.018241985310866,-0.013524613967302,-0.017315012504629
cArc part,wMat,-0.013524613967302,-0.017315012504629,-0.012874348631288,-0.017803819486842,-0.012206433589674,-0.018268218851899
cArc part,wMat,-0.012206433589674,-0.018268218851899,-0.011521784500733,-0.018707573945295,-0.010821339963784,-0.019121282446222
cLn part,wMat,-0.010821339963784,-0.019121282446222,-0.010958415416039,-0.021212649706473
cArc part,wMat,-0.010958415416039,-0.021212649706473,-0.0091369496311489,-0.022058547718239,-0.0072508386026412,-0.022748378306122
cLn part,wMat,-0.0072508386026412,-0.022748378306122,-0.0058689456127906,-0.021172631352624
cArc part,wMat,-0.0058689456127906,-0.021172631352624,-0.0050811204444289,-0.021375384348105,-0.0042863294650164,-0.021548833395739
cArc part,wMat,-0.0042863294650164,-0.021548833395739,-0.0034856622696233,-0.021692740710711,-0.0026802165091436,-0.021806909007563
cLn part,wMat,-0.0026802165091436,-0.021806909007563,-0.0020065261124034,-0.023791536918834
cArc part,wMat,-0.0020065261124034,-0.023791536918834,-4.3858051955795e-018,-0.023876,0.0020065261124034,-0.023791536918834
cLn part,wMat,0.0020065261124034,-0.023791536918834,0.0026802165091436,-0.021806909007563
cArc part,wMat,0.0026802165091436,-0.021806909007563,0.0034856622696233,-0.021692740710711,0.0042863294650164,-0.021548833395739
cArc part,wMat,0.0042863294650164,-0.021548833395739,0.0050811204444289,-0.021375384348105,0.0058689456127906,-0.021172631352624
cLn part,wMat,0.0058689456127906,-0.021172631352624,0.0072508386026412,-0.022748378306122
cArc part,wMat,0.0072508386026412,-0.022748378306122,0.0091369496311489,-0.022058547718239,0.010958415416039,-0.021212649706473
cLn part,wMat,0.010958415416039,-0.021212649706473,0.010821339963784,-0.019121282446222
cArc part,wMat,0.010821339963784,-0.019121282446222,0.011521784500732,-0.018707573945295,0.012206433589674,-0.018268218851899
cArc part,wMat,0.012206433589674,-0.018268218851899,0.012874348631288,-0.017803819486842,0.013524613967302,-0.017315012504629
cLn part,wMat,0.013524613967302,-0.017315012504629,0.015404328869449,-0.018241985310866
cArc part,wMat,0.015404328869449,-0.018241985310866,0.01688288150761,-0.01688288150761,0.018241985310866,-0.015404328869449
cLn part,wMat,0.018241985310866,-0.015404328869449,0.017315012504629,-0.013524613967302
cArc part,wMat,0.017315012504629,-0.013524613967302,0.017803819486842,-0.012874348631288,0.018268218851899,-0.012206433589674
cArc part,wMat,0.018268218851899,-0.012206433589674,0.018707573945295,-0.011521784500733,0.019121282446222,-0.010821339963784
cLn part,wMat,0.019121282446222,-0.010821339963784,0.021212649706473,-0.010958415416039
cArc part,wMat,0.021212649706473,-0.010958415416039,0.022058547718239,-0.0091369496311489,0.022748378306122,-0.0072508386026412
cLn part,wMat,0.022748378306122,-0.0072508386026412,0.021172631352624,-0.0058689456127906
cArc part,wMat,0.021172631352624,-0.0058689456127906,0.021375384348105,-0.0050811204444289,0.021548833395739,-0.0042863294650164
cArc part,wMat,0.021548833395739,-0.0042863294650164,0.021692740710711,-0.0034856622696233,0.021806909007563,-0.0026802165091436
cLn part,wMat,0.021806909007563,-0.0026802165091436,0.023791536918834,-0.0020065261124034
cArc part,wMat,0.023791536918834,-0.0020065261124034,0.023876,-5.8477402607726e-018,0.023791536918834,0.0020065261124034
cLn part,wMat,0.023791536918834,0.0020065261124034,0.021806909007563,0.0026802165091436
cArc part,wMat,0.021806909007563,0.0026802165091436,0.021692740710711,0.0034856622696233,0.021548833395739,0.0042863294650164
cArc part,wMat,0.021548833395739,0.0042863294650164,0.021375384348105,0.0050811204444289,0.021172631352624,0.0058689456127906
cLn part,wMat,0.021172631352624,0.0058689456127906,0.022748378306122,0.0072508386026412
cArc part,wMat,0.022748378306122,0.0072508386026412,0.022058547718239,0.0091369496311489,0.021212649706473,0.010958415416039
cLn part,wMat,0.021212649706473,0.010958415416039,0.019121282446222,0.010821339963784
cArc part,wMat,0.019121282446222,0.010821339963784,0.018707573945295,0.011521784500733,0.018268218851899,0.012206433589674
cArc part,wMat,0.018268218851899,0.012206433589674,0.017803819486842,0.012874348631288,0.017315012504629,0.013524613967302
cLn part,wMat,0.017315012504629,0.013524613967302,0.018241985310866,0.015404328869449
cArc part,wMat,0.018241985310866,0.015404328869449,0.01688288150761,0.01688288150761,0.015404328869449,0.018241985310866
cLn part,wMat,0.015404328869449,0.018241985310866,0.013524613967302,0.017315012504629
cArc part,wMat,0.013524613967302,0.017315012504629,0.012874348631288,0.017803819486842,0.012206433589674,0.018268218851899
cArc part,wMat,0.012206433589674,0.018268218851899,0.011521784500732,0.018707573945295,0.010821339963784,0.019121282446222
cLn part,wMat,0.010821339963784,0.019121282446222,0.010958415416039,0.021212649706473
cArc part,wMat,0.010958415416039,0.021212649706473,0.0091369496311489,0.022058547718239,0.0072508386026412,0.022748378306122
cLn part,wMat,0.0072508386026412,0.022748378306122,0.0058689456127906,0.021172631352624
cArc part,wMat,0.0058689456127906,0.021172631352624,0.0050811204444289,0.021375384348105,0.0042863294650164,0.021548833395739
cArc part,wMat,0.0042863294650164,0.021548833395739,0.0034856622696233,0.021692740710711,0.0026802165091436,0.021806909007563
cLn part,wMat,0.0026802165091436,0.021806909007563,0.0020065261124034,0.023791536918834
cArc part,wMat,0.0020065261124034,0.023791536918834,1.4619350651932e-018,0.023876,-0.0020065261124034,0.023791536918834
cLn part,wMat,-0.0020065261124034,0.023791536918834,-0.0026802165091436,0.021806909007563
cArc part,wMat,-0.0026802165091436,0.021806909007563,-0.0034856622696233,0.021692740710711,-0.0042863294650164,0.021548833395739
cArc part,wMat,-0.0042863294650164,0.021548833395739,-0.0050811204444289,0.021375384348105,-0.0058689456127906,0.021172631352624
cLn part,wMat,-0.0058689456127906,0.021172631352624,-0.0072508386026412,0.022748378306122
cArc part,wMat,-0.0072508386026412,0.022748378306122,-0.0091369496311489,0.022058547718239,-0.010958415416039,0.021212649706473
cLn part,wMat,-0.010958415416039,0.021212649706473,-0.010821339963784,0.019121282446222
cArc part,wMat,-0.010821339963784,0.019121282446222,-0.011521784500732,0.018707573945295,-0.012206433589674,0.018268218851899
cArc part,wMat,-0.012206433589674,0.018268218851899,-0.012874348631288,0.017803819486842,-0.013524613967302,0.017315012504629
cLn part,wMat,-0.013524613967302,0.017315012504629,-0.015404328869449,0.018241985310866
cArc part,wMat,-0.015404328869449,0.018241985310866,-0.01688288150761,0.01688288150761,-0.018241985310866,0.015404328869449
cLn part,wMat,-0.018241985310866,0.015404328869449,-0.017315012504629,0.013524613967302
cArc part,wMat,-0.017315012504629,0.013524613967302,-0.017803819486842,0.012874348631288,-0.018268218851899,0.012206433589674
cArc part,wMat,-0.018268218851899,0.012206433589674,-0.018707573945295,0.011521784500733,-0.019121282446222,0.010821339963784
cLn part,wMat,-0.019121282446222,0.010821339963784,-0.021212649706473,0.010958415416039
cArc part,wMat,-0.021212649706473,0.010958415416039,-0.022058547718239,0.0091369496311489,-0.022748378306122,0.0072508386026412
cLn part,wMat,-0.022748378306122,0.0072508386026412,-0.021172631352624,0.0058689456127906
cArc part,wMat,-0.021172631352624,0.0058689456127906,-0.021375384348105,0.0050811204444289,-0.021548833395739,0.0042863294650164
cArc part,wMat,-0.021548833395739,0.0042863294650164,-0.021692740710711,0.0034856622696233,-0.021806909007563,0.0026802165091436
cLn part,wMat,-0.021806909007563,0.0026802165091436,-0.023791536918834,0.0020065261124034
Part.InsertSketch
end sub

sub codeBag2(part)
Part.InsertSketch
Set swActiveMat = Part.GetActiveSketch()
swSketchMat= createMatFromSWMat(swActiveMat.ModelToSketchXForm)
mSkMat=createMat4x4FromValues(1,0,0,0,1,0,0,0,1,0,0,-2.54e-005)
wMat=mulMat4x4Mat4x4(swSketchMat,mSkMat)
cCir part,wMat,0,0,0.026924
Part.InsertSketch
end sub

sub codeBag3(part)
Part.InsertSketch
Set swActiveMat = Part.GetActiveSketch()
swSketchMat= createMatFromSWMat(swActiveMat.ModelToSketchXForm)
mSkMat=createMat4x4FromValues(0,0,-1,0,1,0,1,0,0,0,0,0)
wMat=mulMat4x4Mat4x4(swSketchMat,mSkMat)
cLn part,wMat,-0.0352044,0,-0.0352044,0.0071966666666667
cLn part,wMat,-0.0352044,0.0071966666666667,-0.034357733333333,0.00635
cLn part,wMat,-0.034357733333333,0.00635,0.0011091333333333,0.00635
cLn part,wMat,0.0011091333333333,0.00635,0.0019558,0.0071966666666667
cLn part,wMat,0.0019558,0.0071966666666667,0.0019558,0
cLn part,wMat,0.0019558,0,-0.0352044,0
cCLn part,wMat,0.0019558,0,-0.0352044,0
Part.InsertSketch
end sub

sub main
set swApp=CreateObject("SldWorks.Application")
code = swApp.RevisionNumber
found = InStr(code, ".")
If (found > 0) Then
  code = Left(code, found-1)
  If (CInt(code) >= 11) Then
    sw2003api=1
  End If
End If
swApp.SetUserPreferenceToggle 11, FALSE
swApp.SetUserPreferenceToggle 97, FALSE
storePath=BrowseForFolder
If (storePath <> "") Then
   If ((Right(storePath, 1) <> "\") And (Right(storePath, 1) <> "/")) Then
       storePath = storePath + "\"
   End If
   createPart0
End If
end sub
