PDA

View Full Version : slide origin of workplane [LISP]


Harry
07-07-2004, 06:20 AM
I like to slide the origin of my current workplane to a new position. This position is known as a 3d point. (Of course, this point is on the wp)

Has anyone any idea how to translate this 3d point into a 2d point to accept it in the command SLIDE_WP_ORIGIN ?

(syntax: ---->(SLIDE_WP_ORIGIN)----|wp|----|2D point|----> )

I must oversee something really simple, just can't find it... :(


Best regards, Harry

Thom Ivancso
07-07-2004, 10:03 PM
Hello Harry,

There is a command in the integration kit called SD-GPNT3D-TO-2D. It is used to convert a 3D point to a 2D point eliminating the Z (W) component.


Hope this helps

Cheers
Thom

Harry
07-08-2004, 01:43 AM
Thank you for your tip to use SD-GPNT3D-TO-2D to convert the 3d point to a 2d point in the current wp. But there is something strange about it...

I like to make a part which has the shape of a drill.
A part has been made with the shape of a block.

After selecting a point (3d!) on a face of this block, a new part must be created with the shape of the drill. I place a c_point on to check the selection. Before drawing the profile of the drill on a wp, the origin of this wp has to slide to the 3d point.
For a reason, this doesn't happend. Has anyone any idea why?



(sd-defdialog 'make_hole_dialog
:dialog-title "Drill Hole"
:variables
'(
(A_PART
:value-type :part-incl-new
:modifies :contents
:title "Part"
:prompt-text "IDENTIFY PART TO BORE...")

(D_CP
:value-type :point-3d
:title "CenterPoint"
:prompt-text "PICK A POINT..."
)

(D_DIAM
:value-type :length
:title "Diameter"
:prompt-text "ENTER DRILL DIAMETER..."
)

(D_DEPTH
:value-type :length
:title "Depth"
:prompt-text "ENTER DRILL DEPTH..."
)

)

:ok-action
'(make_hole A_PART D_CP D_DEPTH D_DIAM)
)



(defun make_hole (A_PRT P1 DP1 DIA)
;create temp wp
(sd-call-cmds
(CREATE_WORKPLANE
:new
:owner "/"
:name "wp_drilltemp"
:PAR_FACE :face P1 :done)
)

;safe current workplane
(setq curr_wp (sd-inq-curr-wp))

(setq curr_prt a_prt)

(sd-call-cmds
(progn
(CREATE_PART
:owner "/"
:name "HOLE_1")

(C_POINT (sd-gpnt3d-to-2d p1))
(SLIDE_WP_ORIGIN (sd-inq-curr-wp) (sd-gpnt3d-to-2d p1) )

(POSITION_WP (sd-inq-curr-wp)
:rotate
:axis
:u
:rotation_angle (sd-deg-to-rad 90)
:done)

)
)

; Now build the profile from user inputs
(setq ang_fact (tan (* (/ (* 2 pi) 360.0) 31.0))) ;calculate tan 31 in degrees
(setq dr_pnt (+ dp1 (* (/ dia 2.0) ang_fact))) ;depth of drill point

(sd-call-cmds (GEOMETRY_MODE :REAL))

(polygon
(gpnt2d 0 0)
(gpnt2d (/ dia 2.0) 0)
(gpnt2d (/ dia 2.0) (* -1.0 dp1))
(gpnt2d 0 (* -1.0 dr_pnt))
:close)

(TURN
:part (sd-inq-curr-part)
:axis :v
:rotation_angle 360
:keep_wp :yes
:keep_profile :yes)

)




Best regards Harry

dorothea
07-08-2004, 10:09 PM
Hi Harry,

I'm not really sure. But have you tried to use the option 'Face Point' from the create workplane dialog? You use the option :PAR_FACE. There you have the possibility to define the origin of the newly created workplane. From my point of view this avoids the later sliding of the origin.

Hope this helps,
Dorothea

Harry
07-14-2004, 12:43 AM
i finally got it work!


(defun make_hole (&key TYPE CP DIAM DEPTH)
(progn
;function: substract list2 from list1
;date : 05-05-2004
;----------------------------------------------------------------------
;input : :TYPE [string] , type of hole ("DRILL" "CHAMBER")
; : :CP [gpnt3d] , centerpoint of hole
; : :DIAM [length] , diameter of hole
; : :DEPTH [length] , depth of hole
;output: name of new made part

;local vars
(let
(a_part_name
a_path_list
ang_fact
dr_pnt
above_surface)

;correction to pop-up hole for annotation
(setf above_surface 0.01)

;create temp wp
(sd-call-cmds
(create_workplane
:new
:owner "/"
:name "wp_drilltemp"
:par_face :face
:face CP
:face_pt CP :done)
)

(setf a_part_name (get_unique_part_name :name "/manifold/drilling/hole"))
(setf a_path_list (sd-pathname-to-pathlist a_part_name))

(sd-call-cmds
(progn

(CREATE_PART
:owner (sd-pathlist-to-pathname (butlast a_path_list))
:name (nth (- (length a_path_list) 1) a_path_list)
);create_part

(POSITION_WP (sd-inq-curr-wp)
:rotate
:axis
:u
:rotation_angle (sd-deg-to-rad 90)
:done)
);progn
)


; Now build the profile from user inputs
(if (string= (sd-string-upcase TYPE) "DRILL")
;get drill point depth
(progn
(setf ang_fact (tan (* (/ (* 2 pi) 360.0) 31.0))) ;calculate tan 31 in degrees
(setf dr_pnt (+ DEPTH (* (/ DIAM 2.0) ang_fact))) ;depth of drill point
);progn
);if

(if (string= (sd-string-upcase TYPE) "CHAMBER")
;no drill point
(setf dr_pnt DEPTH)
);if

(sd-call-cmds (GEOMETRY_MODE :REAL))

;make profile
(POLYGON
(gpnt2d 0 (+ 0 above_surface))
(gpnt2d (/ DIAM 2.0) (+ 0 above_surface))
(gpnt2d (/ DIAM 2.0) (- (* -1.0 DEPTH) above_surface))
(gpnt2d 0 (- (* -1.0 dr_pnt) above_surface))
:close)

;make part from profile
(TURN
:part (sd-inq-curr-part)
:axis :v
:rotation_angle 360
:keep_wp :no
:keep_profile :no)


; ;set part color
; (if (string= (sd-string-upcase TYPE) "DRILL")
;
; (SET_PART_INST_COLOR
; :parts a_part_name
; :color :on
; :color :RGB 1,1,0 :done)
;
; );if

; (if (string= (sd-string-upcase TYPE) "CHAMBER")
; (SET_DEFAULT_PART_COLOR :color :RGB 0,1,0 :done)
; );if

;return code
a_part_name

);let
);progn
);defun



Best regards Harry