PDA

View Full Version : about sheet metal punch_function


aris63
08-03-2004, 08:12 PM
(sha-define-shop-table "ar-rect"
:TABLE-TITLE "Rectangular array"

:COLUMNS
(:HORIZ :VERT :SPACE_X :SPACE_Y :TOT_DIST_X :TOT_DIST_Y :TOOL_ID :DESCR :MIN_THICK :MAX_THICK :PREFERENCE :ADVICE)
:COLUMN-NAMES
("Horiz" "Vert" "Space x" "Space y" "Total Dist x" "Total Dist y" "Tool Id" "Descr" "Min Thick" "Max Thick" "Pref" "Advice")
:UNITS
(:mm :mm :mm :mm :mm :mm nil nil :mm :mm nil nil)
:CONTENTS
(
(10.00 3.00 3.00 3.00 121.00 32.00 "JLS" "array" 0.60 2.50 :PREF "-")
(12.00 3.00 4.00 3.00 115.00 32.00 "JLS" "array" 0.60 2.50 :PREF "-")
(15.00 3.00 5.00 3.00 148.00 21.00 "JLS" "array" 0.60 2.50 :PREF "-")
(15.00 3.00 4.00 4.00 160.00 40.00 "JLS" "array" 0.60 2.50 :PREF "-")
)
:KEY (:HORIZ :VERT :SPACE_X :SPACE_Y :TOT_DIST_X :TOT_DIST_Y )
:DISPLAY (:HORIZ :VERT :SPACE_X :SPACE_Y :TOT_DIST_X :TOT_DIST_Y :PREFERENCE :ADVICE)
:FLAT-TEXT (:TOOL_ID)
:MENU-ENTRY ("{1}x{2}" :HORIZ :VERT)
:HELP "sha_clstr_rect"
; unique, not displayable column entries
:PROF_FNC sha-rect-profile
)




(defun sha-rect-profile
(&key
horiz
vert
space_x
space_y
tot_dist_x
tot_dist_y
&allow-other-keys
)
(let* ((result nil)
(tool-wp (sha-tool-wp))
(dist_x (+ horiz space_x))
(dist_y (+ vert space_y))
(rows (truncate (/ tot_dist_x dist_x) ) )
(cloumn (truncate (/ tot_dist_y dist_y) ) )
(h (/ horiz 2))
(v (/ vert 2))
(ox (if (evenp rows)
(/ (* (- rows 1) dist_x) -2)
(/ (* (- (ceiling (/ rows 2) ) 1) dist_x) -1)
)
)

(oy (if (evenp column)
(/ (* (- column 1) dist_y) -2)
(/ (* (- (ceiling (/ column 2) ) 1) dist_y ) -1)
)
)
(x 0)
(y 0)

)
(create_workplane :new
:name tool-wp
:world_origin
)
;********* create Profile *******
(flet (
(create_rectangle (x y)
(POLYGON
(gpnt2d (- x h) (- y v))
(gpnt2d (- x h) (+ y v))
(gpnt2d (+ x h) (+ y v))
(gpnt2d (+ x h) (- y v))
(gpnt2d (- x h) (- y v))
)
)
)
(dotimes (i (ceiling column) )
(dotimes (j (ceiling rows) )
(create_rectangle (+ x ox) (+ y oy))
(setf x (+ x dist_x))
)
(progn
(setf x 0)
(setf y (+ y dist_y))
)

)


)
;******** create Adjustpoints ******
(C_POINT
0,0
)

(setq result (sha-profile-of-wp tool-wp))
(delete_3d (sha-absolute-name tool-wp))
result
)
)



But the ( dist_x dist_y rows cloumn ) parameter cann't get Variable
l

(setq dist_x (+ horiz space_x))
(dist_y (+ vert space_y))
(rows (truncate (/ tot_dist_x dist_x) ) )
(cloumn (truncate (/ tot_dist_y dist_y) ) )


I hope automate punch_tools
to make rectangle hole .
but lisp code is wrong

somebody can help me

aris63
08-09-2004, 06:06 PM
(setq dist_x (+ horiz space_x))
(dist_y (+ vert space_y))
(rows (truncate (/ tot_dist_x dist_x) ) )
(cloumn (truncate (/ tot_dist_y dist_y) ) )


truncate converts its argument by truncating toward zero; that is, the result is the integer of the same sign as the argument and which has the greatest integral magnitude not greater than that of the argument

but it must like this (x (truncate 5 2) ) or (x ( truncate (/ y 2)) )

The rows and column transform integer

if rows =3.2 --> 3.0
rows=3.6 --> 3.0

column=8.3 --> 8.0
column=8.6 --> 8.0

How to do it

aris63
08-30-2004, 01:06 AM
(rows (truncate (/ tot_dist_x dist_x) ) )
(cloumn (truncate (/ tot_dist_y dist_y) ) )


The answer is


(rows (truncate (/ (* (/ tot_dist_x dist_x) 2) 2) ) )
(cloumn (truncate (/ (* (/ tot_dist_y dist_y) 2) 2) ) )



I solve this problem