- Mục Action: Chọn file Macro đã tạo ở trên Đuôi file có thể là swp hoặc dll tùy vào file đã lưu ở bước tạo Macro
1. Code Matlab:
%Tinh ti so truyen cua tay so 1: ih1 bang cong thuc
%(G.Psimax.rb)/(Memax.io.ipc.Sit)<=ihI<=(m.G.Psi.rb)/(Memax.io.ipc.Sit) %G:Trong luong toan tai oto
%ipc :Ti so truyen cua hop so phu o so truyen cao %Psimax :He so can tong cong cua duong
%Memax: Momen xoan cuc dai
%io:Ti so truyen cua truyen luc chinh %ipc : ipc= 1 :Ti so truyen cua hop so phu %Sit: Hieu suat truyen luc
%ihI: Ti so truyen cua tay so I %m : He so phan bo tai trong
pi=3.14;
G=input('Nhap trong luong toan tai cua oto. G = '); ipc=input('Nhap tst cua hop so phu(thuong =1). ipc = '); Psimax=input('Nhap he so can tong cong cua duong. Psimax ='); rb=input('Nhap ban kinh banh xe. rb= ');
Memax=input('Nhap gia tri momen xoan cuc dai. Memax= '); io=input('Nhap ti so truyen cua truyen luc chinh. io= '); ipc=1;
Sit=input('Nhap hieu suat truyen luc. Sit= '); m=input('Nhap he so phan bo tai trong. m= '); a11=(G*Psimax*rb)/(Memax*io*ipc*Sit);
b11=(m*G*Psimax*rb)/(Memax*io*ipc*Sit);
fprintf('Ti so truyen ih1 trong khoang (%.3f-%.3f)\n ', a11, b11); ih1=input('Chon gia tri ti so truyen ih1= ');
while ((ih1)<(a11))||((ih1)>(b11))
disp('Hay chon ih1 trong khoang cho phep '); ih1=input('Chon lai ih1 = ');
end
disp('Chon ti so truyen cac tay so trung gian '); ihn=input('Nhap gia tri ihn= ');
n=input('Nhap so tay so truyen (khong ke so truyen lui) n= '); q=((ih1)/(ihn))^(1/(n-1));
for i=2:n
ih(i)=(ih1)*(q^(-i));
fprintf('Ti so truyen ih%i(%.6f)\n ', i,ih(i));
end
ihL=1.1*(ih1);
ih=[ih1 ih(2) ih(3) ih(4) ih(5)];
fprintf('Ti so truyen so truyen lui(%.6f)\n ', ihL); disp('Tinh so bo khoang cach truc ');
disp('Khoang cach truc duoc tinh theo cong thuc aw=ka.(Memax)^1/3 '); ka=input('He so kinh nghiem ka= ');
aw=ka*(Memax)^(1/3);
fprintf('aw (%.6f)\n',aw);
aw=input('Chon lai khoang cach truc aw = ');
%Chon mo dun rang %Chon so rang z
%Doi voi hop so 2 truc ti so truyen cua hop so o tay so bat ki duoc tao boi mot cap banh rang an khop duy nhat. Ta tinh so rang z bang cong thuc %Zi=(2aw.cosbetai)/(m.(1+i.hi))
%beta=asin((pi)*m/b)
disp('Tinh toan cac thong so banh rang '); m=ones(1,5); for j=1:5 m(j) = input('Modun m= '); b1=5.*m; b2=6.*m; end fprintf('b (%.3f-%.3f)\n ', b1, b2);
b=input('Chon lai chieu day banh rang dang ma tran b= '); beta=(asin(pi*m./b));
fprintf('beta (%.3f)\n ', beta); Z=2*aw.*(cos(beta))./((1+ih).*m); fprintf('So rang Z (%.3f)\n', Z); Z=input('Chon lai so rang Z= '); Zp=ih.*Z;
fprintf('So rang Zp (%.3f)\n', Zp); disp('Chon lai so rang Zp');
Zp=input('Zp=');
dvc=(Z.*m)./(cos(beta)); dvcp=(Zp.*m)./(cos(beta)); r=(dvc)/2;
rp=(dvcp)/2;
%Tinh va toi uu ben cho banh rang
disp('Tinh va toi uu ben cho banh rang '); disp('Momen tu dong co truyen den '); Mdcsc=Memax;
Mdctc=(Memax).*ih; ip=1;
icc=1;
phimax=input(' Nhap phimax= ');
Mphisc=((phimax)*G*rb)./(icc*io*ip*ih(1)); Mphitc=((phimax)*G*rb)./(icc*io*ip);
%Gia tri momen tinh ben tren truc so cap:
if Mphisc>Mdcsc
fprintf('Hien thi Mdcsc(%.3f)\n ', Mdcsc); Mtbsc=Mdcsc;
else
fprintf('Hien thi Mphisc(%.3f)\n ', Mphisc); Mtbsc=Mphisc;
end
% Gia tri momen tinh ben tren truc thu cap:
Mtbtc=ones(1,5); for i=1:5 if Mphitc<Mdctc(i) Mtbtc(i)=Mphitc; else Mtbtc(i)=Mdctc(i); end end Mtbtc=[Mtbtc(1) Mtbtc(2) Mtbtc(3) Mtbtc(4) Mtbtc(5)];
% Tinh luc tac dung len cac cap banh rang % Tinh luc vong: Pi=(2.Mt)\(Z.ms)
% tinh luc huong kinh: Ri=Pi.(tg(alpha))/(cos(beta)) % tinh luc doc truc: Qi=Pi.tg(beta)
% Ta tinh cho banh rang bi dong va momen tren truc thu cap
Pi=(Mtbtc.*2)./((Zp).*ms)*1000;
%tinh goc an khop alpha
alpha=input('Nhap goc profin goc ');
alphaw=acos((Z+Zp).*m.*cos(alpha)/(2*(aw))); Ri=Pi.*(tan(alpha));
Qi=Pi.*(tan(beta));
%tinh ben uon cho banh rang
%sichmau=Kd*Kms*Kc*Ktp*Kgc*P/(b*pi*m*y*Kbeta)
Kd=input('He so tai trong dong Kd= '); Kms=input('He so ma sat Kms= ');
Kc=input('He so tinh den do cung vung va phuong phap lap truc Kc= '); Ktp=input('He so tinh den tai trong dong phu Ktp= ');
Kgc=input('He so tinh den ung suat tap trung o cac goc luon rang Kgc= '); Kbeta=input('He so tinh den anh huong do trung khop huong chieu truc doi voi suc ben rang Kbeta= ');
y=input('He so dang chan rang (nhap rieng cho tung so) y= '); smu=(Kd*Kms*Kc*Ktp*Kgc).*Pi./(pi*(Kbeta).*m.*y.*b);
disp('Vat lieu che tao banh rang '); smcf=[140 272 360 440 520];
fprintf('Vat lieu thep 50 thuong hoa co do ben uon 140 Mpa '); fprintf('Vat lieu thep 45 thuong hoa co do ben uon 272 Mpa '); fprintf('Vat lieu thep 45 toi cai thien do ben uon 360 Mpa '); fprintf('Vat lieu thep 40Cr toi cai thien do ben uon 440 Mpa '); fprintf('Vat lieu thep 45Cr toi cai thien do ben uon 520 Mpa ');
for i=1:5
if smu(i)<0.8*smcf(1)
disp('Chon thep 50 thuong hoa do ben uon 140 ');
elseif (smu(i)>0.8*smcf(1))&&(smu(i)<0.8*smcf(2)) disp('Chon thep 45 thuong hoa co do ben uon 272 ');
elseif (smu(i)>0.8*smcf(2))&&(smu(i)<0.8*smcf(3)) disp('Chon thep 40Cr toi cai thien do ben uon 440 ');
elseif (smu(i)>0.8*smcf(3))&&(smu(i)<0.8*smcf(4)) disp('Chon thep 40Cr toi cai thien do ben uon 440 ');
elseif (smu(i)>0.8*smcf(4))&&(smu(i)<0.8*smcf(5)) disp('Chon thep 45Cr toi cai thien do ben uon 520 ');
else
disp('Chon loai thep khac ');
end end
disp(' Kiem nghiem rang ve do ben tiep xuc voi vat lieu da chon'); E=0.2; smtxcp=2500; smtx=0.418*cos(beta).*sqrt((Pi.*E)/ (b.*cos(alpha).*sin(alpha)).*(1./r+1./rp)); for i=1:5 if smtx(i)<smtxcp
disp('Vat lieu da chon dam bao dieu kien ben tiep xuc');
else
disp('Ban chon lai vat lieu');
end end
disp('Kiem nghiem rang ve qua tai');
%Khi lam viec mot so rang co the bi qua tai voi he so qua tai Kqt=Tmax/T, %trong do T la momen xoan danh nghia, Tmax la momen xoan qua tai. Do vay
%can kiem nghiem rang ve qua tai dua vao ung suat tiep xuc cuc dai va ung %suat uon cuc dai
kqt=input('Chon gia tri kqt= '); smtxmax=max(smtx).*kqt;
smumax=max(smu).*kqt;
if (smtxmax<smtxcp)&&(smumax<5.2*(10^3))
disp('Vat lieu da chon dam bao ben khi qua tai');
else
disp('Vat lieu da chon khong dam bao dieu kien ben qua tai. Chon lai vat lieu hoac chon lai be rong rang');
end
%Tinh va toi uu ben cho truc so cap
%Chon vat lieu: dua ra cac gia tri ung suat cua vat lieu
smblim=[600 750 850];
smclim=[340 450 550]; %gioi han chay tuong ung voi gioi han ben
disp('smblim=[600 750 850]'); disp('smclim=[340 450 550]');
sm=input('Moi ban nhap gia tri gioi han chay va gioi han ben sm= ');
if sm==[smblim(1) smclim(1)];
fprintf('Ban da chon thep 45 thuong hoa ');
elseif sm==[smblim(2) smclim(2)];
fprintf('Ban da chon thep 45 toi cai thien ');
elseif sm==[smblim(3) smclim(3)];
fprintf('Ban da chon thep 40X toi cai thien ');
end
disp('Chon so bo duong kinh va chieu dai truc '); disp('Chon so bo duong kinh truc ');
aw=79.3; d=0.45*aw;
disp('Chieu dai truc tinh tu hai o bi do'); l=d/0.18;
disp('Tinh ben cho truc so cap khi gai so 1-4');
disp('Chon khoang cach cac doan truc tinh tu banh rang den 2 o bi');
for i=1:4
a(i)=input(' a= '); b(i)=input(' b= ');
%Cac luc tac dung len banh rang chu dong, Pi,Qi,Ri
%Ta chon o dua con; luc doc truc Fat; Fbt la 2 tong luc doc truc ben ngoai
%Do chi tiet quay truyen den o dua con. Ben canh luc doc truc ngoai nay %Trong o con xuat hien luc doc truc Fs do luc huong tam Rtac dung len o %Sinh ra. Tong luc doc truc sinh ra trong o Fa, Fb
Rb(i)= ((Ri(i)).*a(i))./(a(i)+b(i)); Ra(i)=Ri(i)-Rb(i);
Pb(i)=(Pi(i).*a(i))./(a(i)+b(i)); Pa(i)=Pi(i)-Pb(i);
%Gia tri momen lon nhat M(P)max, M(R)max, Tmax,
MP(i)=(Pi(i)).*b(i).*a(i)/(a(i)+b(i)); MR(i)=(Ri(i)).*b(i).*a(i)/(a(i)+b(i)); T(i)=Pi(i).*r(i);
%Momen chong uon
Wu(i)=0.1.*(dvc(i))^3;
smuon(i)=(Mu(i))./(Wu(i)).*(10^-5);
if (smuon(i))<sm(1)
fprintf('Vat lieu ban chon thoa man dieu kien ben uon ');
else
fprintf('Vat lieu ban chon chua thoa man dieu kien ben uon'); fprintf('Moi ban chay lai chuong trinh');
end
%Tinh truc theo xoan
Wx(i)=0.2.*((dvc(i))^3); Tox(i)=(T(i))./(Wx(i));
smth(i)=sqrt((smuon(i))^2+(Tox(i))^2);
%Xac dinh duong kinh truc d>=(T/(0.2[To]))^(1/3)
[To]=input('Chon ung suat xoan cho phep trong khoang (15:30).10^6: To= ');
d(i)=((T(i))/(0.2*[To]))^(1/3);
fprintf('Duong kinh truc (%.3f)\n ', d);
end
disp('Tinh ben cho truc so cap khi gai so 5'); a(5)=input(' a= ');
b(5)=input(' b= ');
%Cac luc tac dung len banh rang chu dong, Pi,Qi,Ri
%Ta chon o dua con; luc doc truc Fat; Fbt la 2 tong luc doc truc ben ngoai
%Do chi tiet quay truyen den o dua con. Ben canh luc doc truc ngoai nay %Trong o con xuat hien luc doc truc Fs do luc huong tam Rtac dung len o %Sinh ra. Tong luc doc truc sinh ra trong o Fa, Fb
Rb(5)= -((Ri(5))*a(5)+Qi(5)*r(5))/(b(5)); Ra(5)=Ri(5)-Rb(5);
Pb(5)=-(Pi(5)*a(5))/(b(5)); Pa(5)=Pi(5)-Pb(5);
%Gia tri momen lon nhat M(P)max, M(R)max, Tmax,
MP(5)=(Pi(5))*a(5); MR(5)=(Ri(5))*a(5); T(5)=Pi(5)*r(5);
%Momen chong uon
Wu(5)=0.1.*(dvc(5))^3;
Mu(5)=sqrt((MP(5))^2+(MR(5))^2); smuon(5)=(Mu(5))./(Wu(5)).*(10^-5);
if (smuon(5))<(sm(1))
fprintf('Vat lieu ban chon thoa man dieu kien ben uon ');
else
fprintf('Vat lieu ban chon chua thoa man dieu kien ben uon'); fprintf('Moi ban chay lai chuong trinh');
end
%Tinh truc theo xoan
Wx(5)=0.2.*((dvc(5))^3); Tox(5)=(T(5))./(Wx(5));
smth(5)=sqrt((smuon(5))^2+(Tox(5))^2);
%Xac dinh duong kinh truc d>=(T/(0.2[To]))^(1/3)
[To]=input('Chon ung suat xoan cho phep trong khoang (15:30).10^6 : To=');
d(5)=((T(5))/(0.2*[To]))^(1/3);
fprintf('Duong kinh truc tieu chuan dkttc=[10 10.5 11 11.5 12 13 14 15 16 17 18 19 20 21 22 24 25 26 28 30 32 34 36 38 40 42 45 48 50 52 55 60 63 65 70 80 85];');
d(1)=input('Chon lai duong kinh truc theo duong kinh truc tieu chuan d1= ');
d(2)=input('Chon lai duong kinh truc theo duong kinh truc tieu chuan d2= ');
d(3)=input('Chon lai duong kinh truc theo duong kinh truc tieu chuan d3= ');
d(4)=input('Chon lai duong kinh truc theo duong kinh truc tieu chuan d4= ');
d(5)=input('Chon lai duong kinh truc theo duong kinh truc tieu chuan d5= ');
disp('Tinh ben cho truc thu cap khi gai so 1-4');
disp('Chon khoang cach cac doan truc tinh tu banh rang den 2 o bi');
for i=1:4
a(i)=input(' a= '); b(i)=input(' b= ');
%Cac luc tac dung len banh rang bi dong, Pi'=Pi,Qi'=Qi,Ri'=Ri
%Ta chon o dua con; luc doc truc Fat; Fbt la 2 tong luc doc truc ben ngoai
%Do chi tiet quay truyen den o dua con. Ben canh luc doc truc ngoai nay %Trong o con xuat hien luc doc truc Fs do luc huong tam Rtac dung len o %Sinh ra. Tong luc doc truc sinh ra trong o Fa, Fb
Rd(i)= ((Ri(i)).*a(i)+Qi(i).*r(i))./(a(i)+b(i)); Rc(i)=Ri(i)-Rb(i);
Pd(i)=(Pi(i).*a(i))./(a(i)+b(i)); Pc(i)=Pi(i)-Pd(i);
%Gia tri momen lon nhat M(P)max, M(R)max, Tmax,
MPt(i)=(Pi(i)).*b(i).*a(i)/(a(i)+b(i)); MRt(i)=(Ri(i)).*b(i).*a(i)/(a(i)+b(i)); Tt(i)=Pi(i).*r(i);
%Momen chong uon
Wut(i)=0.1.*(dvc(i))^3;
Mut(i)=sqrt((MPt(i))^2+(MRt(i))^2); smuont(i)=(Mut(i))./(Wut(i)).*(10^-5);
if (smuont(i))<sm(1)
fprintf('Vat lieu ban chon thoa man dieu kien ben uon ');
else
fprintf('Vat lieu ban chon chua thoa man dieu kien ben uon'); fprintf('Moi ban chay lai chuong trinh');
end
%Tinh truc theo xoan
Wxt(i)=0.2.*((dvc(i))^3); Toxt(i)=(T(i))./(Wx(i));
smth(i)=sqrt((smuont(i))^2+(Toxt(i))^2);
%Xac dinh duong kinh truc d>=(T/(0.2[To]))^(1/3)
[To]=input('Chon ung suat xoan cho phep trong khoang (15:30).10^6 : To=');
dt(i)=((T(i))/(0.2*[To]))^(1/3);
fprintf('Duong kinh truc (%.3f)\n ', dt);
end
disp('Tinh ben cho truc thu cap khi gai so 5'); a(5)=input(' a= ');
%Cac luc tac dung len banh rang bi dong, Pi,Qi,Ri
%Ta chon o dua con; luc doc truc Fat; Fbt la 2 tong luc doc truc ben ngoai
%do chi tiet quay truyen den o dua con. Ben canh luc doc truc ngoai nay %trong o con xuat hien luc doc truc Fs do luc huong tam Rtac dung len o %sinh ra. Tong luc doc truc sinh ra trong o Fa, Fb
Rd(5)= ((Qi(5))*r(5)-Ri(5)*a(5))/(b(5)); Rc(5)=Ri(5)-Rb(5);
Pd(5)=-(Pi(5)*a(5))/(b(5)); Pc(5)=Pi(5)-Pd(5);
%Gia tri momen lon nhat M(P)max, M(R)max, Tmax,
MPt(5)=(Pi(5))*a(5); MRt(5)=(Ri(5))*a(5); Tt(5)=Pi(5)*r(5);
%momen chong uon
Wut(5)=0.1.*(dvc(5))^3;
Mut(5)=sqrt((MPt(5))^2+(MRt(5))^2); smuont(5)=(Mut(5))./(Wut(5)).*(10^-5);
if (smuont(5))<sm(1)
fprintf('Vat lieu ban chon thoa man dieu kien ben uon ');
else
fprintf('Vat lieu ban chon chua thoa man dieu kien ben uon'); fprintf('Moi ban chay lai chuong trinh');
end
%Tinh truc theo xoan
Wxt(5)=0.2.*((dvc(5))^3); Toxt(5)=(T(5))./(Wx(5));
smth(5)=sqrt((smuont(5))^2+(Toxt(5))^2);
%Xac dinh duong kinh truc d>=(T/(0.2[To]))^(1/3)
[To]=input('Chon ung suat xoan cho phep trong khoang (15:30).10^6 : To=');
dt(5)=((T(5))/(0.2*[To]))^(1/3);
fprintf('Duong kinh truc (%.3f)\n ', d(5));
fprintf('Duong kinh truc tieu chuan dkttc=[10 10.5 11 11.5 12 13 14 15 16 17 18 19 20 21 22 24 25 26 28 30 32 34 36 38 40 42 45 48 50 52 55 60 63 65 70 80 85];');
dt1=input('Chon lai duong kinh truc thu cap theo duong kinh truc tieu chuan dt1= ');
dt2=input('Chon lai duong kinh truc thu cap theo duong kinh truc tieu chuan dt2= ');
dt3=input('Chon lai duong kinh truc thu cap theo duong kinh truc tieu chuan dt3= ');
dt4=input('Chon lai duong kinh truc thu cap theo duong kinh truc tieu chuan dt4= ');
dt5=input('Chon lai duong kinh truc thu cap theo duong kinh truc tieu chuan dt5= '); DK=[dt1 dt2 dt3 dt4 dt5]; fileID = fopen('dkttc.txt','w'); fprintf(fileID,'%6s %12s\n','dt1','dt2','dt3','dt4','dt5'); fprintf(fileID,'%6.2f %12.8f\n',DK); fclose(fileID);
2. Code API:Imports SolidWorks.Interop.sldworks Imports SolidWorks.Interop.sldworks Imports SolidWorks.Interop.swconst Imports System.Collections.Generic Imports System.Text.RegularExpressions Imports System.IO Imports System PartialClass SolidWorksMacro PublicSub main()
Dim form As Form1
form = New Form1 form.swApp = Me.swApp form.ShowDialog()
EndSub
''' <summary>
''' The SldWorks swApp variable is pre-assigned for you. ''' </summary>
Public swApp As SldWorks
EndClass
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Collections.Generic
Imports System.Text.RegularExpressions 'thu vien bieu thuc chinh quy
Imports System.IO
Imports System
PublicClass Form1
Public status AsBoolean = True Public FileName AsString = ""
Public swApp As SldWorks 'nhan doi tuong tu` solidworksmacro chuyen sang
PrivateSub btExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btExit.Click
Me.Close() status = False If TextBox1.Text IsNotNothingThen DOSolid(TextBox1.Text) EndIf 'DOSolid(TextBox1.Text) EndSub
PrivateSub btOpen_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btOpen.Click OpenFileDialog1.ShowDialog()
Try
'Dim solid As SolidWorksMacro = New SolidWorksMacro() ' Create an instance of StreamReader to read from a file.
FileName = OpenFileDialog1.FileName
Dim sr As StreamReader = New StreamReader(OpenFileDialog1.FileName) TextBox1.Text = OpenFileDialog1.FileName
'DOSolid(OpenFileDialog1.FileName)
Dim line AsString
'Read and display the lines from the file until the end
Do
line = sr.ReadLine() tbHienthi.Text += line
LoopUntil line IsNothing Catch
' Let the user know what went wrong.
EndTry EndSub
PublicFunction getData(ByVal filename AsString) As List(OfDouble) 'doc file txt va tra lai 1 danh sach cac kick thuoc doc duoc
Dim sr As StreamReader = New StreamReader(filename) 'doc file bat ki
Dim line AsString = ""
' Read and display the lines from the file until the end
Do
line += sr.ReadLine()
ExitDo
LoopUntil line IsNothing
Dim col As MatchCollection = Regex.Matches(line, " \d{1,}\.?\d+") 'Lop Regex tuong trung cho 1 regular expression (bieu thuc chinh quy hay ki tu sieu thuong dung)
' Dung phuong thuc Matches cua myRegex
Dim ValueArr AsNew List(OfDouble)
ForEach m As Match In col
' Access first Group and its value.
Dim g As Group = m.Groups(0)
ValueArr.Add(Double.Parse(g.Value.Trim())) 'cho tat ca cac gia tri tim duoc vao danh sach valueArr
Next
Return ValueArr
EndFunction
'Public Sub main(ByVal filename As String) 'End Sub
'Dim form As Form1 'form = New Form1 'form.ShowDialog()
'If form.TextBox1.Text Is Nothing Then 'End If
Dim ValueArr AsNew List(OfDouble)
'im filename As String = "E:\hoc tap\chuyen nganh\DO AN TOT NGHIEP\m file\dkttc.txt" 'form.TextBox1.Text '"E:\hoc tap\chuyen nganh\DO AN TOT NGHIEP\m file\dkttc.txt"
ValueArr = getData(filename)
Dim swDoc As ModelDoc2 = Nothing Dim swPart As PartDoc = Nothing
Dim swDrawing As DrawingDoc = Nothing Dim swAssembly As AssemblyDoc = Nothing Dim boolstatus AsBoolean = False
Dim longstatus AsInteger = 0
Dim longwarnings AsInteger = 0
swDoc = CType(swApp.ActiveDoc, ModelDoc2)
Dim radius1 AsDouble = 0
Dim length1 AsDouble = 0
Dim radius2 AsDouble = 0
Dim length2 AsDouble = 0
Dim radius3 AsDouble = 0
Dim length3 AsDouble = 0
Dim radius4 AsDouble = 0
Dim length4 AsDouble = 0
Dim radius5 AsDouble = 0
Dim length5 AsDouble = 0
Dim radius6 AsDouble = 0
Dim length6 AsDouble = 0
Dim radius7 AsDouble = 0
Dim length7 AsDouble = 0
Dim radius8 AsDouble = 0
Dim length8 AsDouble = 0
Dim radius9 AsDouble = 0
Dim length9 AsDouble = 0
Dim lengthchamfer AsDouble = 0
Dim lengthchamfer2 AsDouble = 0
Dim i AsInteger For i = 0 To ValueArr.Count - 1 If i = 0 Then radius1 = ValueArr.Item(i) ElseIf i = 1 Then length1 = ValueArr.Item(i) ElseIf i = 2 Then radius2 = ValueArr.Item(i) ElseIf i = 3 Then length2 = ValueArr.Item(i) ElseIf i = 4 Then radius3 = ValueArr.Item(i) ElseIf i = 5 Then length3 = ValueArr.Item(i) ElseIf i = 6 Then radius4 = ValueArr.Item(i) ElseIf i = 7 Then length4 = ValueArr.Item(i) ElseIf i = 8 Then radius5 = ValueArr.Item(i) ElseIf i = 9 Then length5 = ValueArr.Item(i) ElseIf i = 10 Then
radius6 = ValueArr.Item(i) ElseIf i = 11 Then length6 = ValueArr.Item(i) ElseIf i = 12 Then radius7 = ValueArr.Item(i) ElseIf i = 13 Then length7 = ValueArr.Item(i) ElseIf i = 14 Then radius8 = ValueArr.Item(i) ElseIf i = 15 Then length8 = ValueArr.Item(i) ElseIf i = 16 Then radius9 = ValueArr.Item(i) ElseIf i = 17 Then length9 = ValueArr.Item(i) EndIf Next i lengthchamfer = 0.01499999999993 + length1 / 1000 'Extrude2
swDoc = CType(swApp.ActiveDoc, ModelDoc2)
boolstatus = swDoc.Extension.SelectByID2("", "FACE", -0.01340841599693, 0.004877474784337, 0.01499999999993, False, 0,
Nothing, 0)
swDoc.SketchManager.InsertSketch(True) swDoc.ClearSelection2(True)
Dim skSegment As SketchSegment = Nothing
skSegment = CType(swDoc.SketchManager.CreateCircle(0, 0, 0, radius1 / 1000, 0.005847, 0), SketchSegment)
swDoc.ClearSelection2(True)
boolstatus = swDoc.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
Dim myFeature As Feature = Nothing
myFeature = CType(swDoc.FeatureManager.FeatureExtrusion(True,
False, False, 0, 0, length1 / 1000, 0, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, True,
True, True), Feature)
'Chamfer1
swDoc.ISelectionManager.EnableContourSelection = False
boolstatus = swDoc.Extension.SelectByID2("", "EDGE", 0.003817714451657, 0.02021873306671, lengthchamfer, True, 0, Nothing, 0) myFeature = CType(swDoc.FeatureManager.InsertFeatureChamfer(4, 1, 0.001, 0.7853981633975, 0, 0, 0, 0), Feature)
'Extrude3
Dim myModelView As ModelView = Nothing
myModelView = CType(swDoc.ActiveView, ModelView)
boolstatus = swDoc.Extension.SelectByID2("", "FACE", 0.01198311767357, -0.001784087422209, -0.01499999999987, False, 0,
Nothing, 0)
swDoc.SketchManager.InsertSketch(True) swDoc.ClearSelection2(True)
skSegment = CType(swDoc.SketchManager.CreateCircle(0, 0, 0, radius2 / 1000, 0.005847, 0), SketchSegment)
boolstatus = swDoc.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
myFeature = CType(swDoc.FeatureManager.FeatureExtrusion(True,
False, False, 0, 0, length2 / 1000, 0, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, True,
True, True), Feature)
'Chamfer2
lengthchamfer2 = 0.01499999999987 + length2 / 1000 swDoc.ISelectionManager.EnableContourSelection = False
boolstatus = swDoc.Extension.SelectByID2("", "EDGE", 0.01894224929373, -0.0001734028324449, -lengthchamfer2, False, 0,
Nothing, 0)
myFeature = CType(swDoc.FeatureManager.InsertFeatureChamfer(4, 1, 0.001, 0.7853981633975, 0, 0, 0, 0), Feature)
'Extrude4
Dim lengthextrude4 AsDouble = 0
lengthextrude4 = 0.01499999999987 + length2 / 1000
boolstatus = swDoc.Extension.SelectByID2("", "FACE", 0.008251193559033, 0.0001610897875537, -lengthextrude4, False, 0,
Nothing, 0)
swDoc.SketchManager.InsertSketch(True) swDoc.ClearSelection2(True)
skSegment = CType(swDoc.SketchManager.CreateCircle(0, 0, 0, radius3 / 1000, 0.005361, 0), SketchSegment)
swDoc.ClearSelection2(True)
boolstatus = swDoc.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
myFeature = CType(swDoc.FeatureManager.FeatureExtrusion(True,
False, False, 0, 0, length3 / 1000, 0, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, True,
True, True), Feature)
'Extrude5
Dim lengthextrude5 AsDouble = 0
lengthextrude5 = 0.01499999999987 + length2 / 1000 + length3 / 1000
boolstatus = swDoc.Extension.SelectByID2("", "FACE", 0.008251193559033, 0.0001610897875537, -lengthextrude5, False, 0,
Nothing, 0)
swDoc.SketchManager.InsertSketch(True) swDoc.ClearSelection2(True)
skSegment = CType(swDoc.SketchManager.CreateCircle(0, 0, 0, radius4 / 1000, 0.005361, 0), SketchSegment)
swDoc.ClearSelection2(True)
boolstatus = swDoc.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
myFeature = CType(swDoc.FeatureManager.FeatureExtrusion(True,
False, False, 0, 0, length4 / 1000, 0, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, True,
True, True), Feature)
'Extrude6
Dim lengthextrude6 AsDouble = 0
lengthextrude6 = 0.01499999999987 + length2 / 1000 + length3 / 1000 + length4 / 1000
boolstatus = swDoc.Extension.SelectByID2("", "FACE", 0.008251193559033, 0.0001610897875537, -lengthextrude6, False, 0,
Nothing, 0)
swDoc.SketchManager.InsertSketch(True) swDoc.ClearSelection2(True)
skSegment = CType(swDoc.SketchManager.CreateCircle(0, 0, 0, radius5 / 1000, 0.005361, 0), SketchSegment)
swDoc.ClearSelection2(True)
boolstatus = swDoc.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
myFeature = CType(swDoc.FeatureManager.FeatureExtrusion(True,
False, False, 0, 0, length5 / 1000, 0, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, True,
True, True), Feature)
'Fillet
Dim lengthfillet1 AsDouble = 0
lengthfillet1 = lengthextrude6 + length5 / 1000
swDoc.ISelectionManager.EnableContourSelection = False
boolstatus = swDoc.Extension.SelectByID2("", "EDGE", 0.01671005613539, 0.007349916159882, -lengthfillet1, False, 0, Nothing, 0)
swDoc.ClearSelection2(True)
boolstatus = swDoc.Extension.SelectByID2("", "EDGE", 0.01671005613539, 0.007349916159882, -lengthfillet1, False, 1, Nothing, 0)
Dim radiiArray5 As Array = Nothing Dim radiis5(0) AsDouble
Dim setBackArray5 As Array = Nothing Dim setBacks5(-1) AsDouble
Dim pointArray5 As Array = Nothing Dim points5(-1) AsDouble
radiiArray5 = radiis5 setBackArray5 = setBacks5 pointArray5 = points5
myFeature = CType(swDoc.FeatureManager.FeatureFillet(195, 0.002, 0, 0, radiiArray5, setBackArray5, pointArray5), Feature)
'Extrude7
boolstatus = swDoc.Extension.SelectByID2("", "FACE", 0.008251193559033, 0.0001610897875537, -lengthfillet1, False, 0, Nothing, 0)
swDoc.SketchManager.InsertSketch(True) swDoc.ClearSelection2(True)
skSegment = CType(swDoc.SketchManager.CreateCircle(0, 0, 0, radius6 / 1000, 0.005361, 0), SketchSegment)
swDoc.ClearSelection2(True)
boolstatus = swDoc.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
myFeature = CType(swDoc.FeatureManager.FeatureExtrusion(True,
False, False, 0, 0, length6 / 1000, 0, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, True,
True, True), Feature)
Dim lengthchamfer3 AsDouble = 0
lengthchamfer3 = lengthfillet1 + length6 / 1000
swDoc.ISelectionManager.EnableContourSelection = False
boolstatus = swDoc.Extension.SelectByID2("", "EDGE", 0.03185845702, -lengthchamfer3, 0, True, 0, Nothing, 0)
myFeature = CType(swDoc.FeatureManager.InsertFeatureChamfer(4, 1, 0.0005, 0.7853981633975, 0, 0, 0, 0), Feature)
'Extrude8
boolstatus = swDoc.Extension.SelectByID2("", "FACE", 0.008251193559033, 0.0001610897875537, -lengthchamfer3, False, 0,
Nothing, 0)
swDoc.SketchManager.InsertSketch(True) swDoc.ClearSelection2(True)
skSegment = CType(swDoc.SketchManager.CreateCircle(0, 0, 0, radius7 / 1000, 0.005361, 0), SketchSegment)
swDoc.ClearSelection2(True)
boolstatus = swDoc.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
myFeature = CType(swDoc.FeatureManager.FeatureExtrusion(True,
False, False, 0, 0, length7 / 1000, 0, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, True,
True, True), Feature)
'Extrude9
Dim lengthextrude9 AsDouble = 0
lengthextrude9 = lengthchamfer3 + length7 / 1000
boolstatus = swDoc.Extension.SelectByID2("", "FACE", 0.008251193559033, 0.0001610897875537, -lengthextrude9, False, 0,
Nothing, 0)
swDoc.SketchManager.InsertSketch(True) swDoc.ClearSelection2(True)
skSegment = CType(swDoc.SketchManager.CreateCircle(0, 0, 0, radius8 / 1000, 0.005361, 0), SketchSegment)
swDoc.ClearSelection2(True)
boolstatus = swDoc.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
myFeature = CType(swDoc.FeatureManager.FeatureExtrusion(True,
False, False, 0, 0, length8 / 1000, 0, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, True,
True, True), Feature)
'Extrude10
Dim lengthextrude10 AsDouble = 0
lengthextrude10 = lengthextrude9 + length8 / 1000
boolstatus = swDoc.Extension.SelectByID2("", "FACE", 0.008251193559033, 0.0001610897875537, -lengthextrude10, False, 0,
Nothing, 0)
swDoc.SketchManager.InsertSketch(True) swDoc.ClearSelection2(True)
skSegment = CType(swDoc.SketchManager.CreateCircle(0, 0, 0, radius9 / 1000, 0.005361, 0), SketchSegment)
swDoc.ClearSelection2(True)
boolstatus = swDoc.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
myFeature = CType(swDoc.FeatureManager.FeatureExtrusion(True,
False, False, 0, 0, length9 / 1000, 0, False, False, False, False,