KID Examples   

<<< List of Parasolid LISP Functions Chapters Machine Dependency in KID >>>

Contents

[back to top]


E.1 Introduction

These examples are intended to demonstrate a range of modeling activities using KID.

[back to top]


E.2 Example 1

Create a simple parametric curve wire.

 

(modeller start)
(undefine pcurve1)
(define pcurve1 p_paracurve)
(pcurve1 help create)
(pcurve1 dim 4;
         ord 4;
         nseg 1;
         verts´(0  0 0 1
                1  1 0 2
                3 -1 0 2
                4  0 0 1);
         create)
(modeller stop)

[back to top]


E.3 Example 2

A cube and a parametric sheet body are created. The top planar face of the cube is selected and tweaked to the parametric surface of the sheet using ntweak as the surface normal must be reversed.

 

(modeller start)
(undefine blatt_4 f1 blo s1 tf3)
-- create a parametric sheet body

(define blatt_4 p_parasurf)
(blatt_4 dim 3;
         uord 3;
         vord 4;
         nuseg 1;
         nvseg 1;
         verts ´(0.0 20.0  0.0
                 0.0 30.0 10.0
                 0.0 40.0  0.0
                10.0 20.0  0.0
                10.0 30.0 10.0
                10.0 40.0  0.0

                20.0 20.0  0.0
                20.0 30.0 10.0
                20.0 40.0  0.0

                30.0 20.0  0.0
                30.0 30.0 10.0
                30.0 40.0  0.0);
         create)
-- select the parametric face from the sheet body

(define f1 face)
(define s1 surface)
(f1 pick_from ´blatt_4)
(f1 pick_using ´(eq (f1 enquire ´type) "B-surface"))
-- create a B-surface from the parametric face of the sheet

(s1 pick_from ´f1)
(s1 enquire)
-- create a copy of the surface to avoid trying to share 
   across two bodies

( (define s2 surface) replicate ´s1)
-- create a cube, centred under the parametric sheet

(define blo p_block)
(blo x 5; y 5 ; z 5; point ´(15 30 -15); create)
(define tf3 face)
-- select the top face of blo

(tf3 pick_from ´blo)
(tf3 pick_using ´(tf3 clash ´(15 30 -10)))
(modeller mark)
-- tweak top face of cube to the reverse of s1

(tf3 ntweak ´s2)
(modeller stop)

[back to top]


E.4 Example 3

Two identical cylinders are united and the intersection edges are blended using a rolling ball blend.

 

(modeller start)
(undefine c1 c2 e1 b1)
(define c1 p_cylinder)
(define c2 p_cylinder)
(c1 help create)
(c1 radius 10; height 80; point ´(-40 0 0); direction ´(1 0 0); create)
(c2 radius 10; height 80; point ´(0 -40 0); direction ´(0 1 0); create)
(c1 unite ´c2)
(define e1 edge)

-- collect all edges from the resulting body

(e1 pick_from ´c1)

-- only those which are elliptical

(e1 pick_using ´(eq (e1 enquire ´type) ´ellipse))
-- make rolling ball blend

(define b1 p_fillet)
(b1 help apply)
(b1 r1 2)                        
-- apply blend to edges and fix

(b1 apply ´e1)
-- make sure it´s ok

(e1 blend_check) 
(c1 blend_fix)
(graphics open_device ´xwindow)
(graphics sketch ´c1)
(graphics autowindow; clear; hidden)
(modeller stop)

[back to top]


E.5 Example 4

This next example can be used to demonstrate the differing results of varying combinations of arguments for the local operations crsofa and rmfaso .

 

(modeller start)

-- create cube and two spheres

(undefine s1 s2 b0 fred)
(define b0 p_block)
(b0 x 10; y 10; z 10; create)
(define s1 p_sphere)
(define s2 p_sphere)
(s1 radius 2; point ´(5 5 10); create)
(s2 radius 2; point ´(0 0 10); create)
-- unite cube and two spheres, renaming the resulting body

(b0 unite ´s1)
(b0 unite ´s2)
(define fred body)
(fred tag (unite_temp tag))
(graphics open_device ´xwindow)
(graphics hidden ´fred)
-- pick the two spherical faces into f1

(undefine f1)
(define f1 face)
(f1 pick_from ´fred)
(f1 pick_using ´(eq( f1 enquire ´type) ´spherical))
-- set modeller roll point

(modeller mark)
-- copy the two spherical surfaces and create two new bodies
   using the argument ´grow´, leaving the parent body
   unaltered.

(f1 crsofa ´grow)
(graphics clear)
(graphics sketch ´fred)
(graphics clear)
(graphics hidden ´( crsofa_c1 crsofa_c2))
-- rollback to last set mark and use rmfaso to remove the two
   spherical surfaces and create new bodies.

(modeller roll)
(modeller mark)
(f1 rmfaso ´grow ´growp)
(graphics clear)
(graphics hidden ´rmfaso_p1 )
(graphics clear)
(graphics hidden ´(rmfaso_c1 rmfaso_c2))
-- rollback for another combination

(modeller roll)
(modeller mark)
(f1 rmfaso ´cap)
(modeller stop)

[back to top]


E.6 Example 5

A cube is created, and two lines scribed onto the top face creating 3 new faces in place of the original. Two of these new faces are swept in opposite directions, changing the geometry and topology of the cube.

 

Note: This example produces an invalid body.

(modeller start)
(undefine b0 plin1 plin2 f1 f2 pbc1 pbc2)
(define b0 p_block)
(b0 x 20; y 20; z 20; create) 
(modeller mark)
-- the next sections scribe two bounded curves onto the top
   face of the cube, then sweep two of the newly created faces.

(define plin1 p_line)
(plin1 point ´(0 0 20); direction ´(1 0 0); create)
(define pbc1 p_bounded_curve)   
(define f1 face)
(f1 pick_from ´b0)
(f1 pick_using ´(f1 clash ´(0 0 20)))
(pbc1 startp ´(-10 0 20); endp ´(10 0 20))
(pbc1 face ´f1; curve ´plin1; scribe )
(define plin2 p_line )
(plin2 point ´(0 0 20); direction ´(0 -1 0); create) 
(define pbc2 p_bounded_curve)  
(define f2 face)
(f2 pick_from ´b0)
(f2 pick_using ´(f2 clash ´(0 -5 20)))
(pbc2 startp ´(0 0 20); endp ´(0 -10 20))
(pbc2 face ´f2; curve ´plin2; scribe ) 
-- use f1 and f2 to define the faces to be swept

(f1 pick_from ´b0)
(f2 replicate ´f1)
(f1 pick_using ´(f1 clash ´(0 5 20)))
(f2 pick_using ´(f2 clash ´(5 -5 20)))
(f1 sweep ´(0 0 10))                    --> valid
(f2 sweep ´(0 0 -10))                   --> self_intersecting
(graphics open_device ´xwindow)
(graphics sketch ´b0)
(b0 check)                              --> invalid body
(modeller roll)
(modeller stop)

[back to top]

<<< List of Parasolid LISP Functions Chapters Machine Dependency in KID >>>