|
发表于 2020-1-30 15:43:09
|
显示全部楼层
//注意:
// 0)运行宏之前选好要加工的面(虽然是多算,最好自选一个垂直面);
// 1)径向余量与轴向余量用空格隔开,单独输入数字默认是关闭轴向余量;
// 2)由于更改了开始点和结束点,刀路安全自己注意 ;
// 3)容错公差默认为1MM;
// 4)等高刀路自己设置;
FUNCTION MAIN() {
GRAPHICS LOCK
DIALOGS MESSAGE OFF
DIALOGS ERROR OFF
DELETE TOOLPATH FOLDER "Toolpath\MyFolderTop"
DELETE TOOLPATH FOLDER "Toolpath\MyFolderBottom"
STRING $str=input "请输入余量:"
Real $offset=input "请输入底部位置偏置距离:"
STRING ToolName = INPUT ENTITY TOOL "选择刀具"
ACTIVATE TOOL $ToolName
CALL SetBlock()
//生成顶部参考线
CREATE FOLDER "Toolpath" "MyFolderTop"
ACTIVATE FOLDER #
STRING THName=""
CALL Swarf(str,0,'top',THName)
STRING PName=new_entity_name('Pattern')
CREATE PATTERN ;
EDIT PATTERN ; INSERT TOOLPATH ;
EDIT TOOLPATH DIVIDE TYPE RETRACT
PROCESS TPDIVIDE
DELETE TOOLPATH $THName
//生成底部部参考线
CREATE FOLDER "Toolpath" "MyFolderBottom"
ACTIVATE FOLDER #
CALL Swarf(str,offset,'bottom',THName)
EDIT PATTERN $PName INSERT TOOLPATH ;
EDIT TOOLPATH DIVIDE TYPE RETRACT
PROCESS TPDIVIDE
DELETE TOOLPATH $THName
//取刀路参数
FOREACH TH1 IN FOLDER('Toolpath\MyFolderTop') {
REAL X1=ENTITY('Toolpath',TH1.Name).StartPoint.Position.X
REAL Y1=ENTITY('Toolpath',TH1.Name).StartPoint.Position.Y
REAL Z1=ENTITY('Toolpath',TH1.Name).StartPoint.Position.Z-ENTITY('Toolpath',TH1.Name).StartPoint.Distance
REAL X11=ENTITY('Toolpath',TH1.Name).EndPoint.Position.X
REAL Y11=ENTITY('Toolpath',TH1.Name).EndPoint.Position.Y
REAL Z11=ENTITY('Toolpath',TH1.Name).EndPoint.Position.Z-ENTITY('Toolpath',TH1.Name).EndPoint.Distance
FOREACH TH2 IN FOLDER('Toolpath\MyFolderBottom') {
REAL X2=ENTITY('Toolpath',TH2.Name).StartPoint.Position.X
REAL Y2=ENTITY('Toolpath',TH2.Name).StartPoint.Position.Y
REAL Z2=ENTITY('Toolpath',TH2.Name).StartPoint.Position.Z-ENTITY('Toolpath',TH2.Name).StartPoint.Distance
REAL X22=ENTITY('Toolpath',TH2.Name).EndPoint.Position.X
REAL Y22=ENTITY('Toolpath',TH2.Name).EndPoint.Position.Y
REAL Z22=ENTITY('Toolpath',TH2.Name).EndPoint.Position.Z-ENTITY('Toolpath',TH2.Name).EndPoint.Distance
IF ABS(X1-X2)<1 AND ABS(Y1-Y2)<1 {
EDIT PATTERN $PName INSERT SKETCH
ABSOLUTE
XYPLANE
X $X1
Y $Y1
Z $Z1
ADD
X $X2
Y $Y2
Z $Z2
ADD
END
X $X11
Y $Y11
Z $Z11
ADD
X $X22
Y $Y22
Z $Z22
ADD
END
QUIT SSKETCHER ACCEPT
CONTINUE
} ELSEIF ABS(X1-X22)<1 AND ABS(Y1-Y22)<1 {
EDIT PATTERN $PName INSERT SKETCH
ABSOLUTE
XYPLANE
X $X1
Y $Y1
Z $Z1
ADD
X $X22
Y $Y22
Z $Z22
ADD
END
X $X11
Y $Y11
Z $Z11
ADD
X $X2
Y $Y2
Z $Z2
ADD
END
QUIT SSKETCHER ACCEPT
CONTINUE
} ELSE {
CONTINUE
}
}
}
EDIT PATTERN $PName MERGE
CREATE BOUNDARY ; SKETCH \r EDIT BOUNDARY ; INSERT PATTERN ;
DELETE TOOLPATH FOLDER "Toolpath\MyFolderTop"
DELETE TOOLPATH FOLDER "Toolpath\MyFolderBottom"
EDIT RECYCLER DELETE Toolpath ALL
DIALOGS MESSAGE ON
DIALOGS ERROR ON
GRAPHICS UNLOCK
} |
|