Группы пользователей Autodesk


Написание функции command-ended


Окончательная компоновка

 

Окончательная компоновка  

Написание функции command-ended

Теперь, познакомившись с алгоритмом и остановившись на некоторых важных деталях, можно заменить фиктивную функцию отклика gp:command-ended на следующую:

(defun gp:command-ended (reactor command-list

/ objReactor

reactorToChange reactorData

coordinateValues currentPoints

newReactorData newPts

tileList

)

(cond

;; CONDITION 1 - POLYLINE ERASED (Erase command)

;; If one or more polyline borders are being erased (indicated

;; by the presence of *reactorsToRemove*), erase the tiles

;; within the border, then remove the reactor.

(*reactorsToRemove*

(foreach objReactor *reactorsToRemove*

(gp:erase-tiles objReactor)

)

(setq *reactorsToRemove* nil)

)

;; CONDITION 2 - LOST ASSOCIATIVITY (Move, Rotate, etc.)

;; If associativity has been lost (undo, move, etc.), then

;; erase the tiles within each border

;;

((and *lostassociativity* *reactorsToChange*)

(foreach reactorToChange *reactorsToChange*

(gp:erase-tiles reactorToChange)

)

(setq *reactorsToChange* nil)

)

;; CONDITION 3 - GRIP_STRETCH

;; In this case, the associativity of the tiles to the path is

;; kept, but the path and the tiles will need to be

;; recalculated and redrawn. A GRIP_STRETCH can only be

;; performed on a single POLYLINE at a time.

((and (not *lostassociativity*)

*polytochange*

*reactorsToChange*

(member "GRIP_STRETCH" command-list)

;; for a GRIP_STRETCH, there will be only one reactor in

;; the global *reactorsToChange*.

(setq reactorData

(vlr-data (setq reactorToChange

(car *reactorsToChange*)

)

)

)

)

;; First, erase the tiles within the polyline border.

(gp:erase-tiles reactorToChange)

;; Next, get the current coordinate values of the polyline

;; vertices.

(setq coordinateValues

(vlax-safearray->list

(vlax-variant-value

(vla-get-coordinates *polyToChange*)

)

)

)

;; If the outline is a lightweight polyline, you have

;; 2d points, so use utility function xyList->ListOfPoints




Начало  Назад  Вперед