Action:
|
Sets the part to which an entity belongs.
|
|
Filename:
|
scm/scmext/eprt_scm.cxx
|
|
APIs:
|
api_pm_add_entity
|
|
Syntax:
|
(entity:set-part entity [part=active])
|
|
Arg Types:
|
entity
|
entity
|
|
part
|
part
|
|
Returns:
|
entity
|
|
Description:
|
If the
entity already belongs to a different
part, it is removed from the original part, and added to the new part.
|
|
|
Use this extension to move entities from one part to another. The argument entity specifies the entity to move from the original part. The argument part specifies the part to move the entity to. If it already belongs to the given part or active part, it remains unchanged. If it belongs to another part other than the destination part, a new entity is returned having all of the properties of the original. The original entity is deleted from its owning part and is moved to the destination part. Because the original entity is deleted, it is wise to capture the new entity in a variable so that it can be referred to.
|
|
Limitations:
|
If
entity is not a top level entity, it cannot be added to a part that is different from its owner's.
|
|
Example:
|
; entity:set-part
|
|
; Create an active view for display.
|
|
; This view will display the default or part 1.
|
|
(define view1 (view:dl 1 1 256 256))
|
|
;; view1
|
|
; Create a part
|
|
(define first-p (part:new))
|
|
;; first-p
|
|
; Create a 2nd part.
|
|
(define second-p (part:new))
|
|
;; second-p
|
|
; Create a view to display the 2nd part.
|
|
(define view2 (view:dl 1 1 256 256 second-p))
|
|
;; view2
|
|
; Make sure the active part is part 1 or default.
|
|
(env:active-part)
|
|
;; #[part 1]
|
|
; Create a block in the active part.
|
|
(define block1
|
|
|
(solid:block (position 0 0 0)
|
|
|
(position 10 20 30)))
|
|
;; block1
|
|
; Get the ID of the block.
|
|
(entity:part block1)
|
|
;; #[part 1]
|
|
; Move the block from part 1 to part 2.
|
|
(define move (entity:set-part block1 second-p))
|
|
;; move
|
|
; Distributes entities to stream it
|
|
; was not created in.
|
|
(define new-ent (car (part:entities second-p)))
|
|
;; new-ent
|
|
(define new (entity:part new-ent))
|
|
;; new
|