The Scheme example shows how to create a screw using sweeping with laws. One of the first steps is to create a center line for the screw. The center line is used by the
wire-body:offset command with a twist law option to create a helix. This helix then becomes the sweep path.
|
|
A profile for sweeping is then created. The profile is a rectangle, resulting in an auger type thread. If the profile were a diamond or a triangle shape with the hypotenuse facing away from the center line, the result would be a v-shaped thread cut.
|
|
The sweep options include a rail law to specify how the profile is to be oriented as it is swept along a nonplanar path.
|
|
The profile is then swept along the helix path using the sweep options already established. After sweeping is completed, a cylinder blank is created. The threads can then be subtracted from the cylinder, leaving the auger thread screw.
|
|
Scheme Example
|
|
; sweep:law
|
; Sweeping is much faster when the silhouette line calculation
|
; isn't always performed.
|
(option:set "sil" #f)
|
;; #t
|
; Create a center line around which to create the helix.
|
(define wline(wire-body (edge:linear (position 0 0 0)
|
|
(position 0 (law:eval "8*pi") 0))))
|
;; wline
|
(define path(wire-body:offset wline 5 "x"))
|
;; path
|
; Create a profile to be swept.
|
(define p1(edge:linear(position 5 0 0)(position 8 0 0)))
|
;; p1
|
(define p2(edge:linear(position 8 0 0)(position 8 3 0)))
|
;; p2
|
(define p3(edge:linear(position 8 3 0)(position 5 3 0)))
|
;; p3
|
(define p4(edge:linear(position 5 3 0)(position 5 0 0)))
|
;; p4
|
(define profile (wire-body (list p1 p2 p3 p4)))
|
;; profile; profile => #[entity 9 1]
|
|
; Create a rail law to specify the orientation of the profile
|
; as it is swept.
|
(define my_rail (law "vec(-cos(x),0,sin(x))"))
|
;; my_rail
|
; Set up the sweep options.
|
(define my_sweep_ops (sweep:options "rail_law" my_rail))
|
;; my_weep_ops
|
; Perform the sweeping using the profile, the helix path, and
|
; the sweep options that specify the rail law.
|
(define my_sweep (sweep:law profile path my_sweep_ops))
|
;; my_sweep
|
; my_sweep => #[entity 10 1]
|
; Create a cylinder blank.
|
(define my_cylinder (solid:cylinder (position 0 3 0)
|
|
(position 0 (law:eval "8*pi") 0) 7))
|
;; my_cylinder
|
; my_cylinder => #[entity 11 1]
|
; When the screw threads are subtracted (cut out) of the
|
; cylinder blank, the result is a screw.
|
(define my_screw (solid:subtract my_cylinder my_sweep))
|
;; my_screw
|
; my_screw => #[entity 10 1]
|
; Render the screw to see the image as a solid.
|
(render)
|
|
|
|
Figure 1-9. Sweeping a Screw
|