|
经典案例图书 不好意思,是个链轮
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 & "SP50B19_N_15.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)
swSumInfoTitleVar = 0
swSumInfoAuthorVar = 2
Set swModel = swApp.ActiveDoc
swModel.SummaryInfo(swSumInfoAuthorVar) = "CATALOGS*MISUMI"
swModel.SummaryInfo(swSumInfoTitleVar) = "SP50B19-N-15"
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")
part.selectById feat4.Name, "PLANE", 0, 0, 0
codeBag0 part
Set feat4 = getLastFeatureByType(part, "ProfileFeature")
part.selectById feat4.Name, "SKETCH", 0, 0, 0
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")
part.selectById feat6.Name, "PLANE", 0, 0, 0
codeBag1 part
Set feat6 = getLastFeatureByType(part, "ProfileFeature")
part.selectById feat6.Name, "SKETCH", 0, 0, 0
If (sw2003api = 0) Then
part.FeatureCut 1, 0, 1, 0, 0, 0.0087, 0.0087, 1, 1, 0, 0, 0, 0, 0, 0
Else
featMgr.FeatureCut 1, 0, 1, 0, 0, 0.0087, 0.0087, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1
End If
part.CreatePlaneFixed createVec3d(0, 0, 0.02), createVec3d(1, 0, 0.02), createVec3d(0, 1, 0.02), 1
part.BlankRefGeom
Set feat9 = getLastFeatureByType(part, "RefPlane")
part.selectById feat9.Name, "PLANE", 0, 0, 0
codeBag2 part
Set feat9 = getLastFeatureByType(part, "ProfileFeature")
part.selectById feat9.Name, "SKETCH", 0, 0, 0
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
If ver_2001plus = 1 Then
If getEdgeFromModel(part, createVec3d(0.0024585, 0.0359585, 0.02), cylEdge) Then
cylEdge.Select (False)
part.InsertCosmeticThread 0, 0.006, 0.0267, ""
ElseIf getEdgeFromModel(part, createVec3d(0.0024585, 0.0103415, 0.02), cylEdge) Then
cylEdge.Select (False)
part.InsertCosmeticThread 0, 0.006, 0.0267, ""
End If
End If
part.CreatePlaneFixed createVec3d(0, 0, 0.02), createVec3d(1, 0, 0.02), createVec3d(0, 1, 0.02), 1
part.BlankRefGeom
Set feat11 = getLastFeatureByType(part, "RefPlane")
part.selectById feat11.Name, "PLANE", 0, 0, 0
codeBag3 part
Set feat11 = getLastFeatureByType(part, "ProfileFeature")
part.selectById feat11.Name, "SKETCH", 0, 0, 0
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
If ver_2001plus = 1 Then
If getEdgeFromModel(part, createVec3d(0.029911724481983, -0.020108373455204, 0.02), cylEdge) Then
cylEdge.Select (False)
part.InsertCosmeticThread 0, 0.006, 0.029, ""
ElseIf getEdgeFromModel(part, createVec3d(5.7348932845326E-03, -0.006149873455204, 0.02), cylEdge) Then
cylEdge.Select (False)
part.InsertCosmeticThread 0, 0.006, 0.029, ""
End If
End If
part.CreatePlaneFixed createVec3d(0, 0, 0), createVec3d(1, 0, 0), createVec3d(0, 1, 0), 1
part.BlankRefGeom
Set feat13 = getLastFeatureByType(part, "RefPlane")
part.selectById feat13.Name, "PLANE", 0, 0, 0
codeBag4 part
Set feat13 = getLastFeatureByType(part, "ProfileFeature")
part.selectById feat13.Name, "SKETCH", 0, 0, 0
If (sw2003api = 0) Then
part.FeatureCut 1, 0, 1, 0, 0, 0.028, 0.028, 1, 1, 0, 0, 0, 0, 0, 0
Else
featMgr.FeatureCut 1, 0, 1, 0, 0, 0.028, 0.028, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1
End If
part.SetDisplayWhenAdded (True)
part.SetAddToDB (False)
part.SaveAs2 storePath & "SP50B19_N_15.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.028, 0.0077, -0.0278, 0.0075
cLn part, wMat, -0.0278, 0.0075, -0.0002, 0.0075
cLn part, wMat, -0.0002, 0.0075, 0, 0.0077
cLn part, wMat, 0, 0.0077, 0, 0.048225
cLn part, wMat, 0, 0.048225, -0.001105763029981, 0.05235176380902
cArc part, wMat, -0.001105763029981, 0.05235176380902, -1.1771959094371E-03, 0.052458670668058, -1.2989481952388E-03, 0.0525
cLn part, wMat, -1.2989481952388E-03, 0.0525, -7.4010518047612E-03, 0.0525
cArc part, wMat, -7.4010518047612E-03, 0.0525, -7.5228040905629E-03, 0.052458670668058, -0.007594236970019, 0.052351763809021
cLn part, wMat, -0.007594236970019, 0.052351763809021, -0.0087, 0.048225
cLn part, wMat, -0.0087, 0.048225, -0.0087, 0.0367
cArc part, wMat, -0.0087, 0.0367, -8.7585786437627E-03, 0.036558578643763, -0.0089, 0.0365
cLn part, wMat, -0.0089, 0.0365, -0.0278, 0.0365
cLn part, wMat, -0.0278, 0.0365, -0.028, 0.0363
cLn part, wMat, -0.028, 0.0363, -0.028, 0.0077
cCLn part, wMat, 0, 0, -0.028, 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)
cLn part, wMat, -0.15031007674759, -0.11937067538941, 0.15169542307706, -0.11937067538941
cLn part, wMat, 0.15169542307706, -0.11937067538941, 0.15169542307706, 0.12675918914659
cLn part, wMat, 0.15169542307706, 0.12675918914659, -0.15031007674759, 0.12675918914659
cLn part, wMat, -0.15031007674759, 0.12675918914659, -0.15031007674759, -0.11937067538941
cLn part, wMat, -0.05232068588285, -4.3354156372974E-03, -0.039766520815668, -9.2305673960956E-03
cArc part, wMat, -0.039766520815668, -9.2305673960956E-03, -0.039160403174065, -9.9167608959754E-03, -0.039366875722611, -0.010808730178763
cLn part, wMat, -0.039366875722611, -0.010808730178763, -0.048078099649391, -0.021089009794281
cLn part, wMat, -0.048078099649391, -0.021089009794281, -0.034614700695936, -0.021642597994871
cArc part, wMat, -0.034614700695936, -0.021642597994871, -0.033818617514826, -0.022094805561696, -0.033724280858511, -0.023005487015343
cLn part, wMat, -0.033724280858511, -0.023005487015343, -0.038625505310339, -0.035557282510351
cLn part, wMat, -0.038625505310339, -0.035557282510351, -0.025711840653378, -0.031709317281394
cArc part, wMat, -0.025711840653378, -0.031709317281394, -0.024812059897938, -0.031878535208576, -0.024427136877257, -0.0327092423669
cLn part, wMat, -0.024427136877257, -0.0327092423669, -0.024987238134446, -0.046172371938341
cLn part, wMat, -0.024987238134446, -0.046172371938341, -0.014022703715713, -0.038339840019726
cArc part, wMat, -0.014022703715713, -0.038339840019726, -0.013116730592331, -0.038207730919167, -0.012482933589272, -0.038868443771814
cLn part, wMat, -0.012482933589272, -0.038868443771814, -8.6412159897385E-03, -0.051783968428643
cLn part, wMat, -8.6412159897385E-03, -0.051783968428643, -8.1398924578305E-04, -0.040815646188007
cArc part, wMat, -8.1398924578305E-04, -0.040815646188007, -7.4882862497599E-18, -0.040396526130637, 8.1398924578303E-04, -0.040815646188007
cLn part, wMat, 8.1398924578303E-04, -0.040815646188007, 8.6412159897385E-03, -0.051783968428643
cLn part, wMat, 8.6412159897385E-03, -0.051783968428643, 0.012482933589272, -0.038868443771814
cArc part, wMat, 0.012482933589272, -0.038868443771814, 0.013116730592331, -0.038207730919167, 0.014022703715713, -0.038339840019726
cLn part, wMat, 0.014022703715713, -0.038339840019726, 0.024987238134446, -0.046172371938341
cLn part, wMat, 0.024987238134446, -0.046172371938341, 0.024427136877257, -0.0327092423669
cArc part, wMat, 0.024427136877257, -0.0327092423669, 0.024812059897938, -0.031878535208576, 0.025711840653378, -0.031709317281394
cLn part, wMat, 0.025711840653378, -0.031709317281394, 0.038625505310339, -0.035557282510351
cLn part, wMat, 0.038625505310339, -0.035557282510351, 0.033724280858511, -0.023005487015343
cArc part, wMat, 0.033724280858511, -0.023005487015343, 0.033818617514825, -0.022094805561696, 0.034614700695936, -0.021642597994871
cLn part, wMat, 0.034614700695936, -0.021642597994871, 0.04807809964939, -0.021089009794281
cLn part, wMat, 0.04807809964939, -0.021089009794281, 0.039366875722611, -0.010808730178763
cArc part, wMat, 0.039366875722611, -0.010808730178763, 0.039160403174065, -9.9167608959754E-03, 0.039766520815668, -9.2305673960956E-03
cLn part, wMat, 0.039766520815668, -9.2305673960956E-03, 0.05232068588285, -4.3354156372975E-03
cLn part, wMat, 0.05232068588285, -4.3354156372975E-03, 0.040743458762153, 2.5593202874143E-03
cArc part, wMat, 0.040743458762153, 2.5593202874143E-03, 0.040258551513131, 0.003335918687224, 0.040609021363876, 4.1817384070575E-03
cLn part, wMat, 0.040609021363876, 4.1817384070575E-03, 0.050893513961815, 0.012887988074892
cLn part, wMat, 0.050893513961815, 0.012887988074892, 0.037704855844915, 0.015650028688505
cArc part, wMat, 0.037704855844915, 0.015650028688505, 0.036994061119961, 0.016227099718551, 0.037050904333419, 0.017140887967449
cLn part, wMat, 0.037050904333419, 0.017140887967449, 0.043951240108783, 0.028714778301427
cLn part, wMat, 0.043951240108783, 0.028714778301427, 0.030580346745762, 0.02704481364598
cArc part, wMat, 0.030580346745762, 0.02704481364598, 0.029720690182442, 0.027359822705978, 0.029477746914421, 0.028242556348287
cLn part, wMat, 0.029477746914421, 0.028242556348287, 0.032246167416208, 0.041429876743311
cLn part, wMat, 0.032246167416208, 0.041429876743311, 0.020141982573736, 0.035508873401393
cArc part, wMat, 0.020141982573736, 0.035508873401393, 0.019226621299631, 0.035527684371822, 0.018710218222875, 0.036283705520374
cLn part, wMat, 0.018710218222875, 0.036283705520374, 0.017046722133246, 0.049655405189283
cLn part, wMat, 0.017046722133246, 0.049655405189283, 7.5209220547848E-03, 0.040124995746824
cArc part, wMat, 7.5209220547848E-03, 0.040124995746824, 6.6490496672371E-03, 0.039845570167157, 5.9151470679321E-03, 0.04039295219963
cLn part, wMat, 5.9151470679321E-03, 0.04039295219963, -7.9936057773011E-18, 0.0525
cLn part, wMat, -7.9936057773011E-18, 0.0525, -5.9151470679321E-03, 0.04039295219963
cArc part, wMat, -5.9151470679321E-03, 0.04039295219963, -6.6490496672371E-03, 0.039845570167157, -7.5209220547848E-03, 0.040124995746825
cLn part, wMat, -7.5209220547848E-03, 0.040124995746825, -0.017046722133246, 0.049655405189283
cLn part, wMat, -0.017046722133246, 0.049655405189283, -0.018710218222875, 0.036283705520374
cArc part, wMat, -0.018710218222875, 0.036283705520374, -0.019226621299631, 0.035527684371822, -0.020141982573736, 0.035508873401393
cLn part, wMat, -0.020141982573736, 0.035508873401393, -0.032246167416208, 0.041429876743311
cLn part, wMat, -0.032246167416208, 0.041429876743311, -0.029477746914421, 0.028242556348287
cArc part, wMat, -0.029477746914421, 0.028242556348287, -0.029720690182442, 0.027359822705978, -0.030580346745762, 0.02704481364598
cLn part, wMat, -0.030580346745762, 0.02704481364598, -0.043951240108783, 0.028714778301427
cLn part, wMat, -0.043951240108783, 0.028714778301427, -0.037050904333419, 0.017140887967449
cArc part, wMat, -0.037050904333419, 0.017140887967449, -0.036994061119961, 0.016227099718551, -0.037704855844915, 0.015650028688505
cLn part, wMat, -0.037704855844915, 0.015650028688505, -0.050893513961815, 0.012887988074892
cLn part, wMat, -0.050893513961815, 0.012887988074892, -0.040609021363876, 4.1817384070575E-03
cArc part, wMat, -0.040609021363876, 4.1817384070575E-03, -0.040258551513131, 0.003335918687224, -0.040743458762153, 2.5593202874144E-03
cLn part, wMat, -0.040743458762153, 2.5593202874144E-03, -0.05232068588285, -4.3354156372974E-03
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, 0.02)
wMat = mulMat4x4Mat4x4(swSketchMat, mSkMat)
cLn part, wMat, 6.0005711337296E-19, 0.0023, -0.003, 0.0023
cLn part, wMat, -0.003, 0.0023, -0.003, 0.0098
cLn part, wMat, -0.003, 0.0098, -0.0024585, 0.0103415
cLn part, wMat, -0.0024585, 0.0103415, -0.0024585, 0.0359585
cLn part, wMat, -0.0024585, 0.0359585, -0.003, 0.0365
cLn part, wMat, -0.003, 0.0365, -0.003, 0.044
cLn part, wMat, -0.003, 0.044, 2.2349065957258E-18, 0.044
cLn part, wMat, 2.2349065957258E-18, 0.044, 6.0005711337296E-19, 0.0023
cCLn part, wMat, 2.2349065957258E-18, 0.0365, 6.0005711337296E-19, 0.0098
part.InsertSketch
End Sub
Sub codeBag3(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.02)
wMat = mulMat4x4Mat4x4(swSketchMat, mSkMat)
cLn part, wMat, 4.5922738268339E-19, 0, 0.0015, 2.5980762113533E-03
cLn part, wMat, 0.0015, 2.5980762113533E-03, 7.9951905283833E-03, -1.1519237886467E-03
cLn part, wMat, 7.9951905283833E-03, -1.1519237886467E-03, 8.1933932845326E-03, -0.001891626544796
cLn part, wMat, 8.1933932845326E-03, -0.001891626544796, 0.032370224481983, -0.015850126544796
cLn part, wMat, 0.032370224481983, -0.015850126544796, 0.033109927238132, -0.015651923788647
cLn part, wMat, 0.033109927238132, -0.015651923788647, 0.039605117766515, -0.019401923788647
cLn part, wMat, 0.039605117766515, -0.019401923788647, 0.038105117766515, -0.022
cLn part, wMat, 0.038105117766515, -0.022, 4.5922738268339E-19, 0
cCLn part, wMat, 0.031609927238132, -0.01825, 6.4951905283833E-03, -0.00375
part.InsertSketch
End Sub
Sub codeBag4(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)
cLn part, wMat, -0.0025, 0, 0.0025, 0
cLn part, wMat, 0.0025, 0, 0.0025, 0.0098
cLn part, wMat, 0.0025, 0.0098, -0.0025, 0.0098
cLn part, wMat, -0.0025, 0.0098, -0.0025, 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 |
|