;; This is an attempt to move a part once it's loaded ;;;; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% (in-package :custom) (use-package :oli) ;; Set up some globale variables (defvar *NewOrigin_U* nil) (defvar *NewOrigin_V* nil) (defvar *NewOrigin_W* nil) ;;;; =================================================================================================================== (defun sd_aquire_new_wp_origin_xyz (WPName Face 3D_Point) ;;;; =================================================================================================================== ;;Logit (print "Get the 3d point and orientation of the Face and selected point") ;;Look for existing workplanes and delete them (when (sd-inq-workplane-p (sd-pathname-to-obj (format NIL "/~A" WPName))) (sd-call-cmds (delete_3d (format NIL "/~A" WPName))) );when ;;Create a new workplane on the indicated face (sd-call-cmds (create_workplane :new :name (format NIL "~A" WPName) :par_face :face Face :slide_origin 3D_Point :done)) ;;Set global variables for position and orientation (setq *NewOrigin_U* (sd-inq-wp-u-dir (sd-inq-curr-wp)) *NewOrigin_V* (sd-inq-wp-v-dir (sd-inq-curr-wp)) *NewOrigin_W* (sd-call-cmds (measure_dir_3d :face_normal Face)) );setq ;;Logit (print(format nil " >> Here are the indicated points~% >> U = ~A~% >> V = ~A~% >> W = ~A" *NewOrigin_U* *NewOrigin_V* *NewOrigin_W* )) );defun (defun sd_load_then_move_model (Directory PartName NewPnt) ;;==================================================================================================== ;;First, load the part from your directory, this will be .pkg only (sd-call-cmds(universal_load :file (format nil "~A/~A.pkg" Directory PartName )) ;;By default, this will be loaded at 0,0,0. Set default variables (setf 3D_X_Origin (make-gpnt3d :x 1 :y 0 :z 0) 3D_Y_Origin (make-gpnt3d :x 0 :y 1 :z 0) 3D_Z_Origin (make-gpnt3d :x 0 :y 0 :z 1) 3D_Z_Dir0 (make-gpnt3d :x -25.4 :y 25.4 :z 0) );setf (setf 3D_Z_Dir (list 3D_Z_Origin 3D_Z_Dir0) );setf ;;Makre sure the part is in the correct orientation (print(format nil " >> positioning via point direction point")) (sd-call-cmds (position_pa (format nil "/~A" PartName) :match_pt_dir_pt 3D_X_Origin *NewOrigin_U* 3D_Z_Dir *NewOrigin_W* 3D_Y_Origin *NewOrigin_V* )) ;;Move the part to the indicated New Origin (print "Moving the part to the indicated point") (sd-call-cmds(position_pa (format nil "/~A" PartName) :translate :two_ptv 0,0,0 NewPnt )) );defun