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.
|
cell | cell |
Description
This extension returns #t if the input cell is of the type
CELL2D; otherwise, it returns #f.
A CELL2D is a topology entity. It is associated with a lump and consists of a set of faces: DOUBLE_SIDED and BOTH_OUTSIDE. A CELL2D is created using cell:attach with respect to a sheet or mixed-dimension body.
; cell:2d? ; Create a planar face. (define face1 (face:plane (position 0 0 0) 10 10)) ;; face1 ; Make the planar face a 2D cell. (define sheet1 (sheet:2d (sheet:face face1))) ;; sheet1 ; Attach cellular topology to each lump. (define cell1 (cell:attach sheet1)) ;; cell1 ; Determine if the cell is actually a cell. (cell? (car cell1)) ;; #t ; Determine if the cell is a 2D cell. (cell:2d? (car cell1)) ;; #t |
[Top]
cell | cell |
Description
This extension returns #t if the given cell is of the type
CELL3D; otherwise, it returns #f.
A CELL3D is a topology entity. It is a sub-portion of a lump and is bounded by faces. The faces are either SINGLE_SIDED, or DOUBLE_SIDED with BOTH_INSIDE containment. A CELL3D is created using cell:attach with respect to a solid or mixed-dimension body.
; cell:3d? ; Create a solid block. (define block1 (solid:block (position -20 -20 -20) (position 20 20 20))) ;; block1 ; Attach cellular topology to each lump. (define cell1 (cell:attach block1)) ;; cell1 ; Determine if the cellular topology is a cell. (cell? (car cell1)) ;; #t ; Determine if the cellular topology is 3D cell. (cell:3d? (car cell1)) ;; #t |
[Top]
cell | cell |
accuracy | real |
Description
This extension finds the total surface area for all faces in the input cell. If
cell is of the type
CELL3D, this is the area of all faces used once in the cell.
If cell is of the type
CELL2D, this is the area of both sides of each face.
The optional accuracy parameter is a percentage used in the area calculation. If it is not specified, it defaults to 0.1%.
This extension returns the pair: area and accuracy-achieved.
The accuracy achieved is an estimate of the maximum relative error in the area calculation based on the maximum difference between the calculated value and the true value as a fraction of the true value. In the case of a CELL2D, the areas of both sides of all its faces is used in the calculation. In the case of a CELL3D, the areas of all faces in the CELL3D are used just once in the calculation.
; cell:area ; Create a solid block. (define block1 (solid:block (position -20 -20 -20) (position 20 20 20))) ;; block1 ; Attach the solid block to a cell. (define cell1 (cell:attach block1)) ;; cell1 ; Find the area of the cell. (cell:area (car cell1)) ;; (9600 . 0) ; Find the area of the cell ; with the specified accuracy. (cell:area (car cell1) 0.5) ;; (9600 . 0) |
[Top]
entity-list | entity | (entity ...) |
ao | acis-options |
Description
This extension attaches cellular topology to each lump within each solid or
sheet body entity in the given input entity-list. The created cells may be a
sheet body (CELL2D),
a solid body (CELL3D),
or a combination of both. Returns a list of 2D or 3D cell entities.
; cell:attach ; Create a solid block. (define block1 (solid:block (position -20 -20 -20) (position 20 20 20))) ;; block1 ; Attach the solid block to a cell. (define cell1 (cell:attach block1)) ;; cell1 |
[Top]
cell | cell |
position | position |
ao | acis-options |
Description
This extension determines if a given point (position) is inside, outside, or on
the specified cell. cell must be of the type
CELL3D.
; cell:classify-position ; Create a solid block. (define block1 (solid:block (position -20 -20 -20) (position 20 20 20))) ;; block1 ; Attach the block to a cell. (define cell1 (cell:attach block1)) ;; cell1 ; Determine if the following positions ; are on the cell. (cell:classify-position (car cell1) (position 0 0 0)) ;; -1 (cell:classify-position (car cell1) (position 20 0 0)) ;; 0 (cell:classify-position (car cell1) (position 40 0 0)) ;; 1 |
[Top]
cell | cell |
Description
This extension makes a copy of the given cell by creating a one-lump body. The
copy is a solid body for a
CELL3D or a sheet body for a
CELL2D. The newly-created body has cellular topology entity
attached to its lump.
This extension returns the pair (new-body . new-cell).
; cell:copy ; Create a solid block. (define block1 (solid:block (position -20 -20 -20) (position 20 20 20))) ;; block1 ; Attach the solid block to a cell. (define cell1 (cell:attach block1)) ;; cell1 ; Copy the cell. (define copy (cell:copy (car cell1))) ;; copy |
[Top]
entity-list | entity | (entity ... ) |
Description
This extension expands the cells in the sheet or solid bodies in the
entity-list
into supercells. This organizes the cells into a hierarchy based on spatial
proximity, which allows faster cell-based operations. This extension does not
try to expand the cell list into supercells unless 50 or more cells exist. The
return list is the input list.
; cell:expand ; Create a solid sphere. (define sphere1 (solid:sphere (position 0 0 0) 30)) ;; sphere1 ; Attach the sphere to a cell. (define cell1 (cell:attach sphere1)) ;; cell1 ; Expand the cells into supercells. (define expand (cell:expand sphere1)) ;; expand (part:clear) ;; #t ; cell:expand ; Additional example, ; Create a lattice with more cells. (define lattice1 (letrec ((loop (lambda (one two three acc) (if (= one 3) (apply bool:nonreg-unite acc) (if (= two 3) (loop (+ one 1) 0 0 acc) (if (= three 3) (loop one (+ two 1) 0 acc) (let ((org-pos (position (* one 5) (* two 5) (* three 5)))) (loop one two (+ three 1) (cons (solid:block org-pos (position:offset org-pos (gvector 10 10 10))) acc))))))))) (loop 0 0 0 '()))) ;; lattice1 (define cells1 (cell:attach lattice1)) ;; cells1 ; Expand the cells into supercells. (define expand (cell:expand lattice1)) ;; expand |
[Top]
face1 | entity |
face2 | entity |
Description
The
face1
argument is generally the result of a pick operation and is part of the cell in
question.
The optional face2 is a face that is part of the same cell.
The algorithm determines the face's sense (front and back) for face1 and face2. This is used to create a cell relationship. The cells are tested and the proper active cell is returned. This is used as part of graph theory, selective Booleans, and partial sweeping to select the graph elements to keep.
; cell:find ; Create a selective boolean example. (define blank (solid:block (position 0 0 0) (position 25 10 10))) ;; blank ; blank => #[entity 2 1] (define b2 (solid:block (position 5 0 0) (position 10 5 10))) ;; b2 (define b3 (solid:block (position 15 0 0) (position 20 5 10))) ;; b3 (define subtractb2 (solid:subtract blank b2)) ;; subtractb2 (define subtractb3 (solid:subtract blank b3)) ;; subtractb3 (define tool (solid:cylinder (position -5 2.5 5) (position 30 2.5 5)1)) ;; tool (define g (bool:select1 blank tool)) ;; g ; Find the face entities of the blank. (define faces1 (entity:faces blank)) ;; faces1 ; Pick out the fourth face to locate its cell (define fourth-face (list-ref faces1 3)) ;; fourth-face ; Locate the cell associated with this face (cell:find fourth-face) ;; #[entity 35 1] ; Verify that this is one of the cells. (define cells (entity:cells blank)) ;; cells ; To continue the selective boolean example, ; create a list of cells to keep. This list is what ; gets passed to bool:select2. |
[Top]
entity-list | entity | (entity ... ) |
Description
The cell:expand extension expands the cells in
the sheet or solid bodies in the
entity-list
into supercells. The cell:flatten extension removes any supercells
from the cellular topology attached to each sheet or solid body in the input
entity-list. The return value is the
input list.
; cell:flatten ; Create a solid sphere. (define sphere1 (solid:sphere (position 0 0 0) 30)) ;; sphere1 ; Attach the sphere to a cell. (define cell1 (cell:attach sphere1)) ;; cell1 ; Expand the cells into supercells. (define expand (cell:expand sphere1)) ;; expand ; Remove any supercells from the cellular topology. (define flatten (cell:flatten sphere1)) ;; flatten ; cell:flatten ; Additional example, ; Create a lattice with more cells. (define lattice1 (letrec ((loop (lambda (one two three acc) (if (= one 3) (apply bool:nonreg-unite acc) (if (= two 3) (loop (+ one 1) 0 0 acc) (if (= three 3) (loop one (+ two 1) 0 acc) (let ((org-pos (position (* one 5) (* two 5) (* three 5)))) (loop one two (+ three 1) (cons (solid:block org-pos (position:offset org-pos (gvector 10 10 10))) acc))))))))) (loop 0 0 0 '()))) ;; lattice1 (define cells1 (cell:attach lattice1)) ;; cells1 ; Expand the cells into supercells. (define expand1 (cell:expand lattice1)) ;; expand1 ; Remove any supercells from the cellular topology. (define flatten (cell:flatten lattice1)) ;; flatten |
[Top]
cell | cell3d |
color | color |
Description
This extension returns #t if the given cell has the color value "color".
Otherwise, the extension returns #f.
Limitations
This extension does not accept rgb:color values.
; cell:has-volcolor (define b1 (solid:block (position 0 0 0) (position 50 50 50))) ; b1 (cell:attach b1) ; (#[entity 2 1]) (define cell_bottom (car (entity:cells b1))) ; cell_bottom (volcolor:attach cell_bottom red) ; (#[entity 2 1] "red") (volcolor:attach cell_bottom 3) ; (#[entity 2 1] "red" "blue") (cell:has-volcolor cell_bottom red) ; #t (volcolor:remove cell_bottom red) ; (#[entity 2 1] "blue") (cell:has-volcolor cell_bottom red) ; #f |
[Top]
cell | cell |
selector | integer |
accuracy | real |
proj-root | position |
proj-normal | vector |
Description
This extension determines the mass properties of the input cell, which must be
of the type
CELL3D.
The optional accuracy argument is a percentage used in the mass property calculation. If it is not specified, the default is 0.1%.
The optional arguments proj-root for a position and proj-norm for a normal vector specify a projection plane for the calculations. The default for the proj-root argument is the center of the box that bounds the body. The default for the proj-norm normal vector is in the direction of the z-axis.
The return value is an associative list based on the value of the selector.
; cell:massprop ; Create a solid block. (define block1 (solid:block (position -20 -20 -20) (position 20 20 20))) ;; block1 ; Attach the block to a cell. (define cell1 (cell:attach block1)) ;; cell1 ; Get a list of the cell mass properties. (cell:massprop (car cell1) 2) ;; (("volume" . 64000) ("accuracy achieved" . 0) ;; ("center of mass" . #[position 0 0 0]) ;; ("principal moment x" . 17066666.6666667) ;; ("principal axis x" . #[gvector 1 0 0]) ;; ("principal moment y" . 17066666.6666667) ;; ("principal axis y" . #[gvector 0 1 0]) ;; ("principal moment z" . 17066666.6666667) ;; ("principal axis z" . #[gvector 0 0 1]) ;; ("inertia tensor" 17066666.6666667 0 0 0 ;; 17066666.6666667 0 0 0 17066666.6666667)) |
[Top]
lump | LUMP |
[acis-options] | acis-options |
; cell:propagate-cface-attribs ; Create a solid sphere. (define sphere1 (solid:sphere (position 0 0 0) 30)) ;; sphere1 ; Attach the sphere to a cell. (define cell1 (cell:attach sphere1)) ;; cell1 (define lumps (entity:lumps sphere1)) ;; lumps (cell:propagate-cface-attribs (car lumps)) ;;#t |
[Top]
entity-list | entity | (entity ... ) |
Description
This extension removes cellular topology attached to any
LUMP within each sheet or solid body in the input entity-list.
The return value is the input list.
; cell:remove ; Create a solid block. (define block1 (solid:block (position -20 -20 -20) (position 20 20 20))) ;; block1 ; Create a solid sphere. (define sphere1 (solid:sphere (position 0 0 0) 30)) ;; sphere1 ; Attach the solid block and sphere to a cell. (define cell1 (cell:attach (list block1 sphere1))) ;; cell1 ; (#[entity 4 1] #[entity 5 1]) ; Remove the solid block from cell1. (define remove (cell:remove block1)) ;; remove ; Verify the block has been removed. cell1 ;; (#[(deleted) entity 4] #[entity 5 1]) |
[Top]
cell | cell |
[acis-options] | acis-options |
; cell:vacate ; Create a solid sphere. (define sphere1 (solid:sphere (position 0 0 0) 30)) ;; sphere1 ; Attach the sphere to a cell. (define cell1 (cell:attach sphere1)) ;; cell1 (cell:vacate (car cell1)) ;;#t |
[Top]
lump | LUMP |
acis-options | acis-options |
; cells:expand
; Create a solid sphere. (define sphere1 (solid:sphere (position 0 0 0) 30)) ;; sphere1 ; Attach the sphere to a cell. (define cell1 (cell:attach sphere1)) ;; cell1 (define lmp (entity:lumps sphere1)) ; Expand the lump's cells into supercells. (cells:expand (car lmp)) ;; #t |
[Top]
entity | entity |
Description
This extension returns #t if the given entity is of the type cell; otherwise,
it returns #f.
; cell? ; Create a solid block. (define block1 (solid:block (position -20 -20 -20) (position 20 20 20))) ;; block1 ; Create a solid sphere. (define sphere1 (solid:sphere (position 0 0 0) 30)) ;; sphere1 ; Attach the solid block and sphere to a cell. (define cell1 (cell:attach (list block1 sphere1))) ;; cell1 ; Determine if the solid block is a cell type. (cell? block1) ;; #f ; Determine if the lump is a cell type. (cell? (car cell1)) ;; #t (cell? (car (cdr cell1))) ;; #t |
[Top]
body-list | entity | (entity ...) |
Description
This Scheme extension is very useful when doing selective Booleans (for
example,
bool:select1 and
bool:select2), which determine what should be kept and what
should be thrown away by the cells that are selected. entity:cells returns
a list of entities that are cells.
; entity:cells ; Create a selective boolean example. (define blank (solid:block (position 0 0 0) (position 25 10 10))) ;; blank (define b2 (solid:block (position 5 0 0) (position 10 5 10))) ;; b2 (define b3 (solid:block (position 15 0 0) (position 20 5 10))) ;; b3 (define subtractb2 (solid:subtract blank b2)) ;; subtractb2 (define subtractb3 (solid:subtract blank b3)) ;; subtractb3 (define tool (solid:cylinder (position -5 2.5 5) (position 30 2.5 5)1)) ;; tool (define g (bool:select1 blank tool)) ;; g ; Find the cell entities of the blank. (define cells (entity:cells blank)) ;; cells ; Create a list of cells to keep. ; Highlight the portion we're going to throw away. (define highlight (entity:set-highlight (list-ref cells 6) #t)) ;; highlight ; #[entity 12 1] ; Create the list of cells we're going to keep. (define keep-list (list (list-ref cells 0) (list-ref cells 1) (list-ref cells 2) (list-ref cells 3) (list-ref cells 4) (list-ref cells 5) (list-ref cells 7))) ;; keep-list (define select (bool:select2 blank keep-list)) ;; select |
[Top]
entity-list | entity | (entity ...) |
Description
Returns a list of the edges for the input
entity
or
entity-list. Returns an empty list when
no edges are found.
; entity:edges ; Create a solid block. (define block1 (solid:block (position 0 0 0) (position 25 25 25))) ;; block1 ; List the block's edges. (entity:edges block1) ;; (#[entity 3 1] #[entity 4 1] #[entity 5 1] ;; #[entity 6 1] #[entity 7 1] #[entity 8 1] ;; #[entity 9 1] #[entity 10 1] #[entity 11 1] ;; #[entity 12 1] #[entity 13 1] #[entity 14 1]) |
[Top]
entity-list | entity | (entity ...) |
Description
Returns an empty list when no faces are found.
; entity:faces ; Create a solid block. (define block1 (solid:block (position 0 0 0) (position 25 15 5))) ;; block1 ; List the block's faces. (entity:faces block1) ;; (#[entity 3 1] #[entity 4 1] #[entity 5 1] ;; #[entity 6 1] #[entity 7 1] #[entity 8 1]) |
[Top]
entity | entity |
Description
Returns a list of all groups containing an entity.
; entity:groups ; Create a block. (define b1 (solid:block 0 0 0 10 10 10)) ; Create a group containing the block. (define g1 (group b1)) ; Retrieve the groups from an entity. (define l1 (entity:groups b1)) |
[Top]
entity-list | entity | (entity ...) |
Description
Returns a list of the vertices for the input
entity
or
entity-list. Returns an empty list when
no vertices are found.
; entity:vertices ; Create a solid block. (define block1 (solid:block (position 0 0 0) (position 25 25 25))) ;; block1 ; List the block's edges. (entity:vertices block1) ;; (#[entity 3 1] #[entity 4 1] #[entity 5 1] ;; #[entity 6 1] #[entity 7 1] #[entity 8 1] ;; #[entity 9 1] #[entity 10 1]) |
[Top]
entity | entity |
Description
Determines if the given entity is of the type SPAGROUP. This extension returns
#t if the given entity is of the type group; otherwise, it returns #f.
; group? ; Create a block. (define b1 (solid:block 0 0 0 10 10 10)) ; Create a group containing the block. (define g1 (group b1)) ; Is the entity a group? (group? g1) |
[Top]
entity-list | entity | (entity ...) |
Description
Creates a SPAGROUP entity and adds the entities in the input list as members.
Returns the group entity.
; group ; Create a block. (define b1 (solid:block 0 0 0 10 10 10)) ; Create a group containing the block. (define g1 (group b1)) |
[Top]
group | group entity |
entity-list | entity | (entity ...) |
Description
This extension adds all the entities in the input list to the specified group
and returns the list of added entities.
; group:add ; Create a block. (define b1 (solid:block 0 0 0 10 10 10)) ; Create a group containing the block. (define g1 (group b1)) ; Create a sphere. (define s1 (solid:sphere 0 0 0 10)) ; Add the sphere to the group. (group:add g1 s1) |
[Top]
group | group entity |
entity-list | entity | (entity ...) |
Description
This extension tests whether all the entities in the input list are members of
the specified group. Returns TRUE or FALSE.
; group:contains ; Create a block. (define b1 (solid:block 0 0 0 10 10 10)) ; Create a group containing the block. (define g1 (group b1)) ; Does the group contain the specific entity? (group:contains g1 b1) |
[Top]
group | group entity |
[acis-options] | acis-options |
; group:lose ; Create a block. (define b1 (solid:block 0 0 0 10 10 10)) ; Create a group containing the block. (define g1 (group b1)) ; Create a sphere. (define s1 (solid:sphere 0 0 0 10)) ; Add the sphere to the group. (group:add g1 s1) ; Lose the group (group:lose g1) ;;#t |
[Top]
group | group entity |
Description
This extension returns the list of all entities in the specified group and
returns the list of member entities.
; group:members ; Create a block. (define b1 (solid:block 0 0 0 10 10 10)) ; Create a group containing the block. (define g1 (group b1)) ; Retrieve the members of the group. (group:members g1) |
[Top]
group | group entity |
entity-list | entity | (entity ...) |
Description
This extension removes all the entities in the input list from the specified
group. The group entity is lost if all the members are removed. Returns the
list of added entities.
; group:remove ; Create a block. (define b1 (solid:block 0 0 0 10 10 10)) ; Create a group containing the block. (define g1 (group b1)) ; Create a sphere. (define s1 (solid:sphere 0 0 0 10)) ; Add the sphere to the group. (group:add g1 s1) ; Remove the block from the group (group:remove g1 b1) |
[Top]
cell | CELL3D |
color | color |
Description
This extension returns a pair, constructed with the cell and a list of the
volume colors attributes already attached to the cell. If the attachment
operation was successful, the new color is shown on the returned list.
Errors
Attempting to re-attach an already existing attribute volume color.
; volcolor:attach (define b1 (solid:block (position 0 0 0) (position 50 50 50))) ; b1 (cell:attach b1) ;(#[entity 2 1]) (define cell_bottom (car (entity:cells b1))) ; cell_bottom (volcolor:attach cell_bottom red) ; (#[entity 2 1] "red") (volcolor:attach cell_bottom 3) ; (#[entity 2 1] "red" "blue") |
[Top]
cell | cell3d |
Description
This extension returns a list of the attribute volume colors already attached
to the cell. The list of attribute volume colors may differ from the results
shown by (volcolor:query cell) if the cell needs propagation after a boolean
operation.
; volcolor:colors? (define b1 (solid:block (position 0 0 0) (position 50 50 50))) ; b1 (cell:attach b1) ; (#[entity 2 1]) (define cell_bottom (car (entity:cells b1))) ; cell_bottom (volcolor:attach cell_bottom red) ; (#[entity 2 1] "red") (volcolor:attach cell_bottom 3) ; (#[entity 2 1] "red" "blue") (volcolor:attach cell_bottom 5) ; (#[entity 2 1] "red" "blue" "yellow") (volcolor:colors? cell_bottom) ; ("red" "blue" "yellow") (volcolor:remove cell_bottom red) ; (#[entity 2 1] "blue" "yellow") (volcolor:colors? cell_bottom) ; ("blue" "yellow") |
[Top]
cell | cell3d |
Description
This extension returns a list of attribute volume colors for every cface, of
every cshell belonging to the given cell.
; volcolor:query (define b1 (solid:block (position 0 0 0) (position 50 50 50))) ; b1 (cell:attach b1) ;(#[entity 2 1]) (define cell_bottom (car (entity:cells b1))) ; cell_bottom (volcolor:attach cell_bottom red) ; (#[entity 2 1] "red") (volcolor:query cell_bottom) ; ((#[entity 9 1] (#[entity 8 1] "red") (#[entity 7 1] "red") (#[entity 6 1] "red") (#[entity 5 1] "red") (#[entity 4 1] "red") (#[entity 3 1] "red"))) (volcolor:attach cell_bottom 3) ; (#[entity 2 1] "red" "blue") (volcolor:query cell_bottom) ((#[entity 9 1] (#[entity 8 1] "red" "blue") (#[entity 7 1] "red" "blue") (#[entity 6 1] "red" "blue") (#[entity 5 1] "red" "blue") (#[entity 4 1] "red" "blue") (#[entity 3 1] "red" "blue"))) |
[Top]
cell | cell3d |
color | color |
Description
This extension returns a pair, constructed with the cell and a list of the
volume colors atributes that still remain in the cell. Otherwise, this
extension returns a pair (cell . empty_list) when no attributes remain.
Errors
Attempting to remove a non-existing volume color attribute.
; volcolor:remove (define b1 (solid:block (position 0 0 0) (position 50 50 50))) ; b1 (cell:attach b1) ; (#[entity 2 1]) (define cell_bottom (car (entity:cells b1))) ; cell_bottom (volcolor:attach cell_bottom red) ; (#[entity 2 1] "red") (volcolor:attach cell_bottom 3) ; (#[entity 2 1] "red" "blue") (volcolor:remove cell_bottom red) ; (#[entity 2 1] "blue") |
[Top]
© 1989-2007 Spatial Corp., a Dassault Systèmes company. All rights reserved.