Feature Naming Example
List of: Discussion Topic
Subjects: Feature Naming
Contents: Kernel

In this Scheme AIDE example, a profile is swept along a path to create a solid. Before the modeling operation, however, annotation option is turned on while the unhook_annotations option is turned off. This assures that the annotation data remains for the Scheme extensions to be able to query.

A simple sweep path is created for sweeping. Once the profile has been swept with annotations on, the annotation information can be queried. This is typically done by selecting an entity (such as an edge or face) of the resulting body and asking for a list of annotations using entity:annotations. This list of annotations can be further broken down into lists of inputs and outputs using annotation:input and annotation:output.

The annotation:member-name provides a small amount of information through the annotation as to what the owning entity is, such as being a "lateral face" from a sweep operation. entity:annotation-names can also be used to acquire the names of annotations in a list.

Scheme Example

; Turn on annotation options so that annotations are
; automatically created as part of the modeling operation.
(option:set "annotation" #t)
;; #f
; Turn off the unhook annotation option so that termination
; of the modeling operation does not clear annotations.
(option:set "unhook_annotations" #f)
;; #t

; Create a sweep path from a wire body of edges.
(define path1 (wire-body (list

(edge:linear (position 0 0 0)(position 20 0 0))

(edge:circular-3pt (position 20 0 0)


(position 27 0 2.5) (position 30 0 10))

(edge:linear (position 30 0 10)


(position 30 0 20)))))
;; path1

; Sweep the edges into a face body.
(define a_body (sweep:law

(edge:linear ( position 0 3 3)( position 0 3 -3))

(edge:linear ( position 0 3 -3)

( position 0 -3 -3))))
;; a_body
; a_body => #[entity 8 1]

; Create the profile to use in sweeping
(define profile1 (car (entity:faces

(sheet:2d a_body))))
;; profile1
; profile1 => #[entity 9 1]
; Sweep the profile along the path.
(define sweep1 (sweep:law profile1 path1))

; Create some lists for handling purposes.
; in_prof_edges are the edges of the input profile.
(define in_prof_edges (entity:edges profile1))
;; in_prof_edges
; out_sw_faces are the faces of the output swept model.
(define out_sw_faces (entity:faces sweep1))
;; out_sw_faces
; out_sw_edges are the edges of the output swept model.
(define out_sw_edges (entity:edges sweep1))
;; out_sw_edges

; Check the annotations attached to items.
; Create a list of annotations associated with an
; edge of the swept body.
; There are many edges associated with the output swept
; model. This only explores the annotations of the third
; edge.
(define anno1 (entity:annotations

(list-ref out_sw_edges 2)))
; anno1 => (#[entity 93 1])
; Create a list of annotations that are inputs to
; the sweep operation.
(define anno_input1

(annotation:inputs (list-ref anno1 0)))
;; anno_input1
; anno_input1 => (#[entity 94 1] #[entity 95 1])
; See what the annotation names are for a given
; input annotation.
(entity:annotation-names (list-ref anno_input1 0))
;; ("mid_top_vertex" "profile" "profile" "profile")
(entity:annotation-names (list-ref anno_input1 1))
;; ("path" "path" "path" "path" "path" "path" "path"
;; "path" "path" "path" "path" "path" "path" "path"
;; "path" "path")

; Create a second list of annotations from the first
; swept face. There are many to choose from. This only
; uses the first face in the list.
(define anno2 (entity:annotations

(list-ref out_sw_faces 0)))
;; anno2
; anno2 => (#[entity 98 1])
; See what the annotation names are for the
; annotation attached to the first swept face.
(annotation:member-name (list-ref anno2 0)

(list-ref out_sw_faces 0))
;; "lateral_face"

; Create a second list of input annotations,
; but this one is for the annotations of the first
; face of the swept body.
(define anno_input2

(annotation:inputs (list-ref anno2 0)))
;; anno_input2
; anno_input2 => (#[entity 10 1] #[entity 95 1])
; See what the names are for the input annotations.
(entity:annotation-names (list-ref anno_input2 0))
;; ("top_edge" "profile" "profile" "profile"
;; "profile" "profile" "profile" "profile" "profile")
(entity:annotation-names (list-ref anno_input2 1))
;; ("path" "path" "path" "path" "path" "path" "path"
;; "path" "path" "path" "path" "path" "path" "path"
;; "path" "path")

; Create a list of annotations just from one of the
; four input profile edges.
(define anno3 (entity:annotations

(list-ref in_prof_edges 0)))
;; anno3
; anno3 => (#[entity 97 1] #[entity 98 1]
; #[entity 99 1] #[entity 100 1] #[entity 96 1]
; #[entity 101 1] #[entity 102 1] #[entity 103 1]
; #[entity 104 1])
(annotation:member-name (list-ref anno3 0)

(list-ref in_prof_edges 0))
;; "profile"
(annotation:member-name (list-ref anno3 8)

(list-ref in_prof_edges 0))
;; "top-edge"

; Create a list of output annotations from the
; list of annotations associated with an edge (the
; first edge) of the input profile.
(define output1 (annotation:outputs

(list-ref anno3 0)))
;; output1
; output1 => (#[entity 19 1])
; See what the name is of the annotation.
(entity:annotation-names (list-ref output1 0))
; ("lateral_face")

Example 8-1. Annotation Used With Sweeping

If you were converting Example 8-1 into C++, you would turn on annotations using api_set_int_option. It would not be required to turn off unhook_annotations.

After setting the options, establish the profile, path, and required sweep_options. The api_sweep_with_options then automatically creates the annotations.

Use api_find_annotations to acquire an entity list of the annotations for further query. Each entity annotation has its own set of methods for query, as well as their own "is_" functions to ascertain the annotation class type.

When finished, use api_clear_annotations to remove the annotations before the next modeling operation is performed.

The following example repeats the sweep modeling operation from Example 8-1. Then it loads the file annotation.scm which is an interactive rubberbander for seeing annotation information.

Scheme Example

; -------------------------------------------
; Repeat of code in Example 8-1. (below)
; -------------------------------------------

; Turn on annotation options so that annotations are
; automatically created as part of the modeling operation.
(option:set "annotation" #t)
;; #f
; Turn off the unhook annotation option so that termination
; of the modeling operation does not clear annotations.
(option:set "unhook_annotations" #f)
;; #t

; Create a sweep path from a wire body of edges.
(define path1 (wire-body (list

(edge:linear (position 0 0 0)(position 20 0 0))

(edge:circular-3pt (position 20 0 0)


(position 27 0 2.5) (position 30 0 10))

(edge:linear (position 30 0 10)


(position 30 0 20)))))
;; path1

; Sweep the edges into a face body.
(define a_body (sweep:law

(edge:linear ( position 0 3 3)( position 0 3 -3))

(edge:linear ( position 0 3 -3)

( position 0 -3 -3))))
;; a_body
; a_body => #[entity 8 1]

; Create the profile to use in sweeping
(define profile1 (car (entity:faces

(sheet:2d a_body))))
;; profile1
; profile1 => #[entity 9 1]
; Sweep the profile along the path.
(define sweep1 (sweep:law profile1 path1))

; -------------------------------------------
; Repeat of code in Example 8-1. (above)
; -------------------------------------------

; The scm/examples directory contains a script file that
; can be used to view annotations in an interactive manner.
; Make sure "annotation.scm" is copied to the directory where
; "acisinit.scm" is located, or know its path.
(load "annotation.scm")

; This loads the annotation rubberbander. When you move the
; mouse over entities of the swept model, the selected entity is
; in one color and its associated input or output is in another.

Example 8-2. Annotation Used With Sweeping

In Example 8-2 after the sweep modeling operation is performed, the file annotation.scm is loaded for the interactive rubberbander for seeing annotation information.

Move the mouse over topology to pick and highlight. Information about the selected item is output to the scheme command window. When an item is selected with the left mouse button, more information about that item is output to the command window. The right mouse button toggles between picking vertices and edges. Picking faces is always active. Use the shift key to pick back faces, or specifically, the second face from the front face.

The selected entity is white when using the annotation rubberbander. Output entities are red, input entities are magenta, and all other entities remain green.
PDF/KERN/08ANNO.PDF
HTM/DATA/KERN/KERN/08ANNO/0007.HTM