Inch Metric: Difference between revisions
From Macros Wiki
Jump to navigationJump to search
New page: ! change current part units from inch to metric<br> ! or metric to inch, ie swap the current units<br> <br> a1$ = "This macro will change the units of the current part"<br> a2$ = "from inc... |
MikeONeill (talk | contribs) No edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
! change current part units from inch to metric | {| | ||
! or metric to inch, ie swap the current units | |! change current part units from inch to metric | ||
|- | |||
a1$ = "This macro will change the units of the current part" | |! or metric to inch, ie swap the current units | ||
a2$ = "from inch to metric, or metric to inch, scaling the" | |- | ||
a3$ = "geometry and solids accordingly" | | | ||
|- | |||
message "%a1$\n%a2$\n%a3$" | |a1$ = "This macro will change the units of the current part" | ||
|- | |||
check part_open, "You must have a part open to run this macro" | |a2$ = "from inch to metric, or metric to inch, scaling the" | ||
|- | |||
get_part_data units, iunits | |a3$ = "geometry and solids accordingly" | ||
|- | |||
if iunits=1 then goto inch | | | ||
|- | |||
yesno "This part is Metric, Do you want to convert it to Inch ?", iyesno, "Inch Metric Macro" | |message "%a1$\n%a2$\n%a3$" | ||
if iyesno=0 then stop "Finished - no action taken" | |- | ||
| | |||
! convert from metric to inch | |- | ||
! --------------------------- | |check part_open, "You must have a part open to run this macro" | ||
|- | |||
scale = 1/25.4 | | | ||
iunits= 1 | |- | ||
|get_part_data units, iunits | |||
goto scale | |- | ||
| | |||
! convert from inch to metric | |- | ||
! --------------------------- | |if iunits=1 then goto inch | ||
|- | |||
<nowiki>:</nowiki>inch | | | ||
scale = 25.4 | |- | ||
iunits= 0 | |yesno "This part is Metric, Do you want to convert it to Inch ?", iyesno, "Inch Metric Macro" | ||
|- | |||
<nowiki>:</nowiki>scale | |if iyesno=0 then stop "Finished - no action taken" | ||
|- | |||
set_part_data units, iunits | | | ||
|- | |||
|! convert from metric to inch | |||
! part units, now scale the geometry | |- | ||
|! --------------------------- | |||
select_all_geo | |- | ||
scale_geo scale | | | ||
|- | |||
yesno "Scale the stock ?", iyesno, "Inch Metric Macro" | |scale = 1/25.4 | ||
if iyesno=0 then redraw | |- | ||
if iyesno=0 then stop "Finished - stock size not changed" | |iunits= 1 | ||
|- | |||
! get the current stock | | | ||
! --------------------- | |- | ||
|goto scale | |||
get_part_data stock_x1, x1 | |- | ||
get_part_data stock_y1, y1 | | | ||
get_part_data stock_z1, z1 | |- | ||
get_part_data stock_x2, x2 | |! convert from inch to metric | ||
get_part_data stock_y2, y2 | |- | ||
get_part_data stock_z2, z2 | |! --------------------------- | ||
|- | |||
| | |||
! | |- | ||
|<nowiki>:</nowiki>inch | |||
|- | |||
! change the current stock | |scale = 25.4 | ||
! ------------------------ | |- | ||
|iunits= 0 | |||
set_part_data stock_x1, x1*scale | |- | ||
set_part_data stock_y1, y1*scale | | | ||
set_part_data stock_z1, z1*scale | |- | ||
set_part_data stock_x2, x2*scale | |<nowiki>:</nowiki>scale | ||
set_part_data stock_y2, y2*scale | |- | ||
set_part_data stock_z2, z2*scale | | | ||
|- | |||
|set_part_data units, iunits || ! change the part units | |||
! | |- | ||
| | |||
|- | |||
zoom_view 0 | |! any solids will have been scaled by changing the | ||
|- | |||
message "Finished" | |! part units, now scale the geometry | ||
|- | |||
| | |||
|- | |||
|! get the current WorkGroup number and | |||
|- | |||
|! then scale the geometry in each WorkGroup | |||
|- | |||
| | |||
|- | |||
|iCurWG = CURRENT_WG_NUMBER | |||
|- | |||
| | |||
|- | |||
|GET_WG_LIST | |||
|- | |||
|iNumWG = NUMBER_OF_WGS ! save the current WG number | |||
|- | |||
| | |||
|- | |||
|LOCAL ListWG(iNumWG+1) ! in case there is only 1 WG, arrays size must be more than 1 | |||
|- | |||
|GET_WG_LIST ListWG ! get a list of all WGs | |||
|- | |||
| | |||
|- | |||
|FOR i=1 TO iNumWG | |||
|- | |||
| iWG = ListWG(i) | |||
|- | |||
| | |||
|- | |||
| SET_WG iWG ! select this WG | |||
|- | |||
| | |||
|- | |||
| select_all_geo ! select all geomtry in this WG | |||
|- | |||
| scale_geo scale ! scale all geometry in this WG | |||
|- | |||
|NEXT i | |||
|- | |||
| | |||
|- | |||
|SET_WG iCurWG ! reselect the current WG | |||
|- | |||
| | |||
|- | |||
|yesno "Scale the stock ?", iyesno, "Inch Metric Macro" | |||
|- | |||
|if iyesno=0 then redraw | |||
|- | |||
|if iyesno=0 then stop "Finished - stock size not changed" | |||
|- | |||
| | |||
|- | |||
|! get the current stock | |||
|- | |||
|! --------------------- | |||
|- | |||
| | |||
|- | |||
|get_part_data stock_x1, x1 | |||
|- | |||
|get_part_data stock_y1, y1 | |||
|- | |||
|get_part_data stock_z1, z1 | |||
|- | |||
|get_part_data stock_x2, x2 | |||
|- | |||
|get_part_data stock_y2, y2 | |||
|- | |||
|get_part_data stock_z2, z2 | |||
|- | |||
| | |||
|- | |||
|! get_part_data stock_z1, z1 || ! you would use these variables | |||
|- | |||
|! get_part_data stock_z2, z2 || ! for a turned part | |||
|- | |||
|! get_part_data stock_rad, rr | |||
|- | |||
| | |||
|- | |||
|! change the current stock | |||
|- | |||
|! ------------------------ | |||
|- | |||
| | |||
|- | |||
|set_part_data stock_x1, x1*scale | |||
|- | |||
|set_part_data stock_y1, y1*scale | |||
|- | |||
|set_part_data stock_z1, z1*scale | |||
|- | |||
|set_part_data stock_x2, x2*scale | |||
|- | |||
|set_part_data stock_y2, y2*scale | |||
|- | |||
|set_part_data stock_z2, z2*scale | |||
|- | |||
| | |||
|- | |||
|! get_part_data stock_z1, z1 || ! you would use these variables | |||
|- | |||
|! get_part_data stock_z2, z2 || ! for a turned part | |||
|- | |||
|! get_part_data stock_rad, rr | |||
|- | |||
| | |||
|- | |||
|zoom_view 0 | |||
|- | |||
| | |||
|- | |||
|message "Finished" | |||
|} |
Latest revision as of 19:05, 4 December 2020
! change current part units from inch to metric | |
! or metric to inch, ie swap the current units | |
a1$ = "This macro will change the units of the current part" | |
a2$ = "from inch to metric, or metric to inch, scaling the" | |
a3$ = "geometry and solids accordingly" | |
message "%a1$\n%a2$\n%a3$" | |
check part_open, "You must have a part open to run this macro" | |
get_part_data units, iunits | |
if iunits=1 then goto inch | |
yesno "This part is Metric, Do you want to convert it to Inch ?", iyesno, "Inch Metric Macro" | |
if iyesno=0 then stop "Finished - no action taken" | |
! convert from metric to inch | |
! --------------------------- | |
scale = 1/25.4 | |
iunits= 1 | |
goto scale | |
! convert from inch to metric | |
! --------------------------- | |
:inch | |
scale = 25.4 | |
iunits= 0 | |
:scale | |
set_part_data units, iunits | ! change the part units |
! any solids will have been scaled by changing the | |
! part units, now scale the geometry | |
! get the current WorkGroup number and | |
! then scale the geometry in each WorkGroup | |
iCurWG = CURRENT_WG_NUMBER | |
GET_WG_LIST | |
iNumWG = NUMBER_OF_WGS ! save the current WG number | |
LOCAL ListWG(iNumWG+1) ! in case there is only 1 WG, arrays size must be more than 1 | |
GET_WG_LIST ListWG ! get a list of all WGs | |
FOR i=1 TO iNumWG | |
iWG = ListWG(i) | |
SET_WG iWG ! select this WG | |
select_all_geo ! select all geomtry in this WG | |
scale_geo scale ! scale all geometry in this WG | |
NEXT i | |
SET_WG iCurWG ! reselect the current WG | |
yesno "Scale the stock ?", iyesno, "Inch Metric Macro" | |
if iyesno=0 then redraw | |
if iyesno=0 then stop "Finished - stock size not changed" | |
! get the current stock | |
! --------------------- | |
get_part_data stock_x1, x1 | |
get_part_data stock_y1, y1 | |
get_part_data stock_z1, z1 | |
get_part_data stock_x2, x2 | |
get_part_data stock_y2, y2 | |
get_part_data stock_z2, z2 | |
! get_part_data stock_z1, z1 | ! you would use these variables |
! get_part_data stock_z2, z2 | ! for a turned part |
! get_part_data stock_rad, rr | |
! change the current stock | |
! ------------------------ | |
set_part_data stock_x1, x1*scale | |
set_part_data stock_y1, y1*scale | |
set_part_data stock_z1, z1*scale | |
set_part_data stock_x2, x2*scale | |
set_part_data stock_y2, y2*scale | |
set_part_data stock_z2, z2*scale | |
! get_part_data stock_z1, z1 | ! you would use these variables |
! get_part_data stock_z2, z2 | ! for a turned part |
! get_part_data stock_rad, rr | |
zoom_view 0 | |
message "Finished" |