Solids

From Macros Wiki
Jump to: navigation, search
!    create a shape and revolve it
!    revolve again and boolean results
!    create a cuboid and boolean
 
a1$ = "This macro will create revolved and extruded solids"
a2$ = "and boolean them together. It will also transform the"
a3$ = "resulting solid by translating, rotating and mirror it"
 
message "%a1$\n%a2$\n%a3$"
 
!    start a new part and set the stock size
!    ---------------------------------------
 
new_part "Example.vnc"
set_part_data mdd_name, "VMill3a"  !    3 axis vertical mill
set_part_data units, 1  !    inches
 
set_part_data stock_x1, -6
set_part_data stock_y1, -6
set_part_data stock_z1, -6
set_part_data stock_x2, 6
set_part_data stock_y2, 6
set_part_data stock_z2, 6
 
set_view iso
zoom_view 0  !    zoom full
 
message "Create contour, without rotation", "Solids", 1
 
contour [
start 2, 2
line 5, 2
line 4, 4
line 2, 4
line 2, 2
]
 
iref = ContourRef
 
message "select contour", "Solids", 1
 
deselect_all_geo
select_shape iref
redraw
 
message "Revolve Horizontal 180 degrees about Y 1", "Solids", 1
 
deselect_all_geo
select_shape iref
 
revolve h, 1, 180
solref1 = SolidRef
redraw
 
message "Revolve Vertical 120 degrees", "Solids", 1
 
deselect_all_geo
select_shape iref
 
revolve v, 0.1, 120
solref2 = SolidRef
redraw
 
message "Union 2 solids", "Solids", 1
 
solid_union solref1, solref2
solref1 = SolidRef
 
message "Delete the contour and select the new solid", "Solids", 1
 
deselect_all_geo
delete_shape iref
select_solid solref1
 
redraw
 
message "Create a cuboid", "Solids", 1
 
contour [
start 1, 1
line 4, 1
line 4, 4
line 1, 4
line 1, 1
]
 
iref = ContourRef
 
redraw
 
deselect_all_geo
select_shape iref
 
extrude -2, 2
solref2 = SolidRef
 
deselect_all_geo
delete_shape iref
 
redraw
 
message "Boolean 2 solids together", "Solids", 1
 
solid_union solref1, solref2
!   solid_subtract solref1, solref2
!   solid_intersect solref1, solref2
 
solref = SolidRef
 
clear_select
redraw
 
message "Select top and select the new solid", "Solids", 1
 
select_solid solref
set_view top
zoom_view 0
redraw
 
message "Translate", "Solids", 1
translate_solid 1, 0.2, 0.3
redraw
 
message "Mirror X", "Solids", 1
mirror_solid x, 0.2
redraw
 
message "Mirror Y", "Solids", 1
mirror_solid y, 0.3
redraw
 
message "Rotate", "Solids", 1
rotate_solid 0, 0, 60
redraw
 
message "Select ISO view", "Solids", 1
 
set_view iso
 
message "Scale the solid to 1/4 size", "Solids", 1
 
scale_solid 0.25
redraw
 
message "Back to top view, move the solid left then copy and translate it"
 
set_view top
 
translate_solid -4, 0, 0
translate_solid 3, 0, 0, 3
redraw
 
stop "Finished"