;;----------------------------------------------------------------------------- ;; for PTC Creo Elements/Direct Modeling ;; better known as CoCreate SolidDesigner ;; Description: ;; save and restore clipping plane of current view port ;; * by retrieving active clipping plane ;; * and store to PDS ;; * single function call, which can be used e.g. on a UI button ;; ;;----------------------------------------------------------------------------- ;; ;; Filename : clippingplane_persist.lsp ;; Version : 1.2 ;; Datum : 24nov2017 ;; Author : der_Wolfgang@forum@cad.de & MiBr@forum@cad.de ;; Download : ?? osd.cad.de (may be or not) ?? ;; SD-Version : developed with 19.00 - might be compatible with 14.x, too ;; Reference : http://ww3.cad.de/foren/ubb/Forum29/HTML/004576.shtml ;; ;; thanks goes to Michael (MiBr@forum@cad.de) for the task+testing+feedback+etc ;; ;; enhancement: instead of handling the pathname of the owner of the clipping plane ;; we use the sysid via sd-inq-obj-contents-sysid/sd-sysid-to-obj ;; adv#1: the owner can be shifted around in the overall model structure ;; from: /model_0815/baugruppy/part42/Schnitzebene5 ;; to : /model-4712/OberBau/UnterBau/part42/Schnitzebene5 ;; adv#2: when storing both IDs we can 1st look for the instance sysid ;; if not found, we will have a fall back using the contents sysid ;; ;;----------------------------------------------------------------------------- (in-package :custom) (use-package '(:oli :elan)) (sd-defdialog 'clippingplane_persist :dialog-control :sequential :dialog-type :interrupt :toolbox-button t :ok-action '(ManageCurrentClippingPlane) :local-functions '( ;;----------------------------------------------------------------------------- ;; input: obj a selection item to look into, either assembly or part ;; output: returns list of names of clipping planes ;; ;; todo: the get_selection call looks expensive. How to replace? ;;----------------------------------------------------------------------------- (getClippingPlaneNames (obj) ;; list of names of existing clipping planes in the given object (mapcar #'oli:sd-inq-elem-name (sd-call-cmds (get_selection :focus_type *sd-feature-seltype* :select (if (sd-inq-part-p obj) :in_part :in_assembly) obj :select_done) :failure (progn (pprint (sd-inq-error-obj :code)) ;(display (sd-inq-error-obj :message)) nil) ) ); end mapcar ) ;end getClippingNames ;;----------------------------------------------------------------------------- (ManageCurrentClippingPlane () (let (clip-item clip-owner-path clip-name clip-pds) (if (sd-inq-vp-model-clipping-enabled-p (sd-inq-current-vp)) (progn (setq clip-item (clipping-active-feats (sd-inq-current-vp))) (setq clip-owner-path (sd-inq-obj-pathname clip-item)) (setq clip-name (sd-inq-elem-name clip-item)) (setq clip-pds (list :owner clip-owner-path :name clip-name)) (sd-set-persistent-data "ALL" "Schnittebene" clip-pds :subkey :clipping-active :store-flag t) (clipping_deactivate (sd-inq-current-vp)) ) ;; else (progn (setq clip-pds (sd-get-persistent-data "ALL" "Schnittebene" :subkey :clipping-active)) (when (listp clip-pds) (setq clip-owner-path (getf clip-pds :owner)) (setq clip-name (getf clip-pds :name)) (when (and (sd-string-p clip-owner-path) (sd-string-p clip-name)) (setq clip-item (sd-pathname-to-obj clip-owner-path)) (when (and (sel_item-p clip-item) (find clip-name (getClippingPlaneNames clip-item) :test #'oli:sd-string=)) (clipping_activate (sd-inq-current-vp) :FULL_NAME :START_NAME clip-owner-path :CLIPPING clip-name :END_NAME) ) ) ) ) ;; end else ) ;; end if ) ;; end let ) ;; end ManageCurrentClippingPlane ) ;; end local-functions ) ;; end defdialog