Scheme Extensions |
|
|
Technical Article |
Scheme is a public domain programming language, based on the LISP language, that uses an interpreter to run commands. ACIS provides extensions (written in C++) to the native Scheme language that can be used by an application to interact with ACIS through its Scheme Interpreter. The C++ source files for ACIS Scheme extensions are provided with the product. Spatial's Scheme based demonstration application, Scheme ACIS Interface Driver Extension (Scheme AIDE), also uses these Scheme extensions and the Scheme Interpreter. |
ent-list | entity | (entity ...) |
neutral-root | position |
bending-axis | gvector |
bending-direction | gvector |
bend-radius | real |
bend-angle | real |
bend-width | real |
center-bend-flag | boolean |
bend-position* | position |
Description
Neutral-root,
bending-axis, and
bending-direction
define a neutral plane for the bending operation. A neutral plane is the
location where the material is not stretched or compressed during bending. The
material above the neutral plane (along bending direction) is compressed and
the material below the neutral plane is stretched. The location of a neutral
plane varies with the type of material to be bent.
; entity:bend ; Create a block (define block1 (solid:block (position -30 -10 0) (position 30 10 1))) ;; block1 ; OUTPUT Original ; Bend the block (entity:bend block1 (position 0 0 0) (gvector 0 1 0) (gvector 0 0 1) 10 30) ; 0.930000 = api_time ; 0.000000 = updating ;; #[entity 2 1] ; OUTPUT Example ;Additional Example 2 ; Create several objects for bending (part:clear) ;; #t ; Create a block (define a-part (solid:block (position -24 -8 -0.25) (position 40.5 8 0.25))) ;; a-part ; Create another block (define b2 (solid:block (position -8 -24 -.25) (position 8 24 .25))) ;; b2 ; Unite the blocks (define a-part (bool:unite a-part b2)) ;; a-part ; Create another small block (define a-block (solid:block (position -2 -22 -1) (position 2 -2 1))) ;; a-block ; Subtract a-block from a-part (define a-part (bool:subtract a-part a-block)) ;; a-part ; Create another small block (define b-block (solid:block (position 20 -22 -.25) (position 24 -2 0.25))) ;; b-block ; Unite the blocks (define a-part (bool:unite a-part b-block)) ;; a-part ; Visualize positions for local bending ; by creating spots (define a-spot (solid:sphere (position 6 -8.25 0.25) 0.25)) ;; a-spot ; Change the spot's color (entity:set-color a-spot 1) ;; () (define b-spot (solid:sphere (position -6 -8.25 0.25) 0.25)) ;; b-spot ; Change the spot's color (entity:set-color b-spot 3) ;; () (define c-spot (solid:sphere (position 22 -8.25 0.25) 0.25)) ;; c-spot ; Change the spot's color (entity:set-color c-spot 6) ;; () ; OUTPUT Original ; Only radius is given, space warp whole part. (define bend (entity:bend a-part (position 0 -8. 0) (gvector 1 0 0) (gvector 0 0 1) 20)) ;; bend ; OUTPUT Example ; Additional Example 3 ; Create several objects for bending ; Create a block (part:clear) ;; #t (define a-part (solid:block (position -24 -8 -0.25) (position 40.5 8 0.25))) ;; a-part ; Create another block (define b2 (solid:block (position -8 -24 -.25) (position 8 24 .25))) ;; b2 ; Unite the blocks (define a-part (bool:unite a-part b2)) ;; a-part ; Create another small block (define a-block (solid:block (position -2 -22 -1) (position 2 -2 1))) ;; a-block ; Subtract a-block from a-part (define a-part (bool:subtract a-part a-block)) ;; a-part ; Create another small block (define b-block (solid:block (position 20 -22 -.25) (position 24 -2 0.25))) ;; b-block ; Unite the blocks (define a-part (bool:unite a-part b-block)) ;; a-part ; Visualize positions for local bending ; by creating spots (define a-spot (solid:sphere (position 6 -8.25 0.25) 0.25)) ;; a-spot ; Change the spot's color (entity:set-color a-spot 1) ;; () (define b-spot (solid:sphere (position -6 -8.25 0.25) 0.25)) ;; b-spot ; Change the spot's color (entity:set-color b-spot 3) ;; () (define c-spot (solid:sphere (position 22 -8.25 0.25) 0.25)) ;; c-spot ; Change the spot's color (entity:set-color c-spot 6) ;; () ; OUTPUT Original (define bend (entity:bend a-part (position 0 -8. 0) (gvector 1 0 0) (gvector 0 0 1) 0.5 90 )) ;; bend ; OUTPUT Example ; Additional Example 4 ; Create several objects for bending ; Create a block (part:clear) ;; #t (define a-part (solid:block (position -24 -8 -0.25) (position 40.5 8 0.25))) ;; a-part ; Create another block (define b2 (solid:block (position -8 -24 -.25) (position 8 24 .25))) ;; b2 ; Unite the blocks (define a-part (bool:unite a-part b2)) ;; a-part ; Create another small block (define a-block (solid:block (position -2 -22 -1) (position 2 -2 1))) ;; a-block ; Subtract a-block from a-part (define a-part (bool:subtract a-part a-block)) ;; a-part ; Create another small block (define b-block (solid:block (position 20 -22 -.25) (position 24 -2 0.25))) ;; b-block ; Unite the blocks (define a-part (bool:unite a-part b-block)) ;; a-part ; Visualize positions for local bending ; by creating spots (define a-spot (solid:sphere (position 6 -8.25 0.25) 0.25)) ;; a-spot ; Change the spot's color (entity:set-color a-spot 1) ;; () (define b-spot (solid:sphere (position -6 -8.25 0.25) 0.25)) ;; b-spot ; Change the spot's color (entity:set-color b-spot 3) ;; () (define c-spot (solid:sphere (position 22 -8.25 0.25) 0.25)) ;; c-spot ; Change the spot's color (entity:set-color c-spot 6) ;; () ; OUTPUT Original ; Bend area given is not complete, but ; command intelligence completes the bend ; automatically (define bend (entity:bend a-part (position 0 -8. 0) (gvector 1 0 0) (gvector 0 0 1) 0.5 90 0 #f (position 6 -8.25 0.25))) ;; bend ; OUTPUT Example |
[Top]
body | entity |
start | position |
end | position |
initial-rail | gvector |
edge | edge |
final-rail | law |
; entity:bend-to-curve ; Define geometry to demonstrate command. (option:set "match_paren" #f) ;; #t (cond ( ( = 0 (length (part:views))) (view:dl))) ;; #f (define color (view:set-bg-color 7)) ;; color (part:clear) ;; #t ; Make a spring edge (define handiness #t) ;; handiness (define pitch1 10) ;; pitch1 (define pitch_degrees1 1440) ;; pitch_degrees1 (define axis_point (position 0 0 0))) ;; axis_point (define axis_vector (gvector 0 1 0)) ;; axis_vector (define start_position (position 0 0 6)) ;; start_position (define spring (edge:spring axis_point axis_vector start_position handiness pitch1 pitch_degrees1)) ;; spring ; Create the part to warp. (define height 40) ;; height (define hneg (- 0 height)) ;; hneg (define width 1) ;; width (define wneg (- 0 width)) ;; wneg (define ent (solid:block (position wneg 5 wneg) (position width (- height 5) width))) ;; ent (define move (entity:move ent -10 0 0)) ;; move (define zoom (zoom-all)) ;; zoom ; OUTPUT Original (render:rebuild) ;; () (define start (position 0 0 0)) ;; start (define end (position 0 height 0)) ;; end (define e1 (edge:linear start end )) ;; e1 (define w1 (wire-body e1)) ;; w1 (define rail (gvector 0 0 1)) ;; rail (define final_rail (law "norm (cross (law1, dcur (edge2,1)))" axis_vector spring)) ;; final_rail (define final_rail_simple (law "law1" (gvector 0 0 1))) ;; final_rail_simple (define bend (entity:bend-to-curve ent start end rail spring)) ; 6.329000 = api_time ; 0.020000 = redrawing ;; bend ; Color the bend for better illustration. (define color (entity:set-color bend 3)) ;; color ; Zoom in better. (define zoom (zoom-all)) ;; zoom ; OUTPUT Result ; Render the object. (render) ;; () ; OUTPUT Rendered Result |
[Top]
ent-list | entity | (entity ...) |
acis-opts | acis-options |
Description
The face(s) and edges of an entity (body or face) are replaced with analytic
surfaces and curves, if possible. Otherwise, they are replaced with their
B-spline approximations.
; entity:simplify ; Create the geometry to illustrate command. (option:set "match_paren" #f) ;; #t (cond (( = 0 (length (part:views))) (view:gl))) ;; #f (define view (view:edges #t)) ;; view (define color (view:set-bg-color 7)) ;; color (part:clear) ;; #t (define profile (edge:ellipse (position 0 0 0) (gvector 0 0 1)10)) ;; profile (define opts (sweep:options "draft_law" "sin(x)")) ;; opts (define sweep (sweep:law profile (gvector 0 0 10) opts)) ;; sweep (define zoom (zoom-all)) ;; zoom (face:types) ; entity:(entity 3 1) ; face:(entity 4 1) face_type:sweepsur-spline ; face:(entity 5 1) face_type:Plane ; face:(entity 6 1) face_type:Plane ;; #t ; simplify the entity (define simplify (entity:simplify sweep)) ;; simplify ; show that the faces have been simplified. (face:types) ; entity:(entity 3 1) ; face:(entity 4 1) face_type:exactsur-spline ; face:(entity 5 1) face_type:Plane ; face:(entity 6 1) face_type:Plane ;; #t |
[Top]
body | entity | (entity . . .) |
position1 | position |
position2 | position |
distance1 | real |
distance2 | real |
continuity | integer |
Description
Entity stretching is a specialized space warping operation. The
position1
and
position2
arguments represent endpoints of the axis along which stretching is to be
performed, and can be either inside or outside the body. The region within
which stretching is to occur is bounded by the two planes through
position1
and
position2, and normal to this axis.
The distance1 and distance2 parameters are real numbers that specify the translations of the non-stretched portions of the body. Typically, distance1 is chosen to be 0, indicating that the portion of the body below the stretch's starting region retains its position. If a nonzero value for distance1 is specified, on the other hand, the entire body is translated along the stretch axis by the given distance before the stretch is performed.
Let heightA be the distance between position1 and position2.
Let heightB be heightA + (distance2 - distance1).
Let heightR be heightB/heightA.
Then heightR represents the amount of scaling to apply to the stretch region of the body, along the stretch axis. (If heightR=1, therefore, no stretching or scaling need be applied.)
The continuity value can be 0 or 1, and refers to G0 and G1 continuity between the stretched and unstretched sections. The interpolation function uses a linear polynomial to obtain G0 continuity. To obtain G1 continuity, it uses a piece of a sine function. (The advantage of the sine function over a degree-3 polynomial is that its inverse is well-defined.)
; entity:stretch ; Create an entity (define ent (solid:cone (position 0 0 -40) (position 0 0 40) 30 5)) ;; ent (define e1 (edge:linear (position 35 0 -40) (position 10 0 40) )) ;; e1 (define w1(wire-body e1)) ;; w1 (define e2 (edge:linear (position -35 0 -40) (position -10 0 40) )) ;; e2 (define w2(wire-body e2)) ;; w2 (define unite (bool:unite ent w1 w2)) ;; unite (define continuity 0) ;; continuity ; OUTPUT Original (define stretch (entity:stretch ent (position 0 0 -20) (position 0 0 20) 0 -30 continuity)) ;; stretch ; OUTPUT Result ; Render for a better view. (render) ;; () ; OUTPUT Rendered Result |
[Top]
body | entity |
position1 | position |
position2 | position |
theta1 | real |
theta2 | real |
continuity | integer |
Description
Entity twisting is a specialized space warping operation. The
position1
and
position2
are of type position. They represent endpoints of an axis about which twisting
is to be performed and can be either inside or outside the body. Two planes are
formed at the
position1
and
position2
positions which are normal to the axis. They specify the region of the body
where twisting is to occur.
The theta1 and theta2 parameters are real numbers that specify in degrees the orientation of the non-twisted portions of the body. Typically, theta1 is 0, meaning that the portion of the body below the twist's starting region retains its orientation to the coordinate system. If a nonzero value for theta1 is specified, the entire body is transformed about the axis by the given amount before performing the twist.
The difference between theta1 and theta2 represents the amount in degrees that the twist region is warped around the axis. Both theta1 and theta2 can be greater than or multiples of +/- 360 degrees to provide more turns in the twisting region.
The continuity value can be 0, 1, or 2 and refer to G0, G1, and G2 continuity. The interpolation function uses a linear, cubic, or quintic polynomial to obtain G0, G1, or G2 continuity between twisted and untwisted sections.
; entity:twist ; Create some geometry to twoist. (define block1 (solid:block (position 10 20 30) (position 0 0 -30))) ;; block1 ; OUTPUT Original ; Twist the blank. (define pos1 (position 5 10 20)) ;; pos1 (define pos2 (position 5 10 -20)) ;; pos2 (define theta2 (law:eval "2*360")) ;; theta2 (define twist1 (entity:twist block1 pos1 pos2 0 theta2 2)) ;; twist1 (render) ;; () ; OUTPUT Example ; Additional Example 2 ; Create some geometry to twoist. (define c1 (solid:cylinder (position 0 0 0) (position 0 0 40) 5)) ;; c1 (define c2 (solid:cylinder (position 0 -5 0) (position 0 -5 40) 3)) ;; c2 (define c3 (solid:cylinder (position 0 5 0) (position 0 5 40) 3)) ;; c3 (define blank (solid:subtract c1 c2)) ;; blank (define blank (solid:subtract c1 c3)) ;; blank ; OUTPUT Original ; Twist the blank. (define screw (entity:twist blank (position 0 0 0) (position 0 0 40) 0 (law:eval "2*360") 0)) ;; screw (render) ;; () ; OUTPUT Example ; Additional Example 3 ; Create some geometry to twoist. (define c1 (solid:cylinder (position 0 0 0) (position 0 0 40) 5)) ;; c1 (define c2 (solid:cylinder (position 0 -5 0) (position 0 -5 40) 3)) ;; c2 (define c3 (solid:cylinder (position 0 5 0) (position 0 5 40) 3)) ;; c3 (define blank (solid:subtract c1 c2)) ;; blank (define blank (solid:subtract c1 c3)) ;; blank ; OUTPUT Original ; Twist the blank. (define screw (entity:twist blank (position 0 -10 5) (position 0 10 35) 0 (law:eval "0.25*360") 0)) ;; screw (render) ;; () ; OUTPUT Example |
[Top]
ent-list | entity | (entity ...) |
law | law | string |
; law:warp ; Create a block for warping. (define block1 (solid:block (position -20 -10 -15) (position 20 10 15))) ;; block1 ; Set the color of the block (entity:set-color block1 3) ;; () (define cyl1 (solid:cylinder (position 0 -15 0) (position 0 15 0) 10)) ;; cyl1 ; Set the color of the cylinder (entity:set-color cyl1 6) ;; () ; OUTPUT Original (define subtract (solid:subtract block1 cyl1)) ;; subtract (define law (law:warp block1 "vec (x,y+3* (sin (x*.5)),z)")) ;; law ; OUTPUT Result |
[Top]
© 1989-2007 Spatial Corp., a Dassault Systèmes company. All rights reserved.