lzg8877 发表于 2022-4-7 17:14:05

求个小程序,求挤压比,谢谢


求个铝材挤压比的程序,请大师帮个忙,!先谢!先谢!



Linqu 发表于 2022-4-8 07:15:49

楼主这是挤压模具厂的设计吗

夏生生 发表于 2022-4-8 09:27:54

不应该是面积的比值吗?挤压后容重变了?

lzg8877 发表于 2022-4-8 09:49:44

一样的,面积和重量 可以转的

lzg8877 发表于 2022-4-8 09:50:18

是的同行吗?

夏生生 发表于 2022-4-8 10:40:49

本帖最后由 夏生生 于 2022-4-9 22:10 编辑

大概是这么个意思,根据自己需求去改吧
(defun c:tt (/         xty-sys-makeFbylst   do_bt1
         do_bt2   area3         callback   dcllst
         dcl_id   en         tmpf
         )
(defun xty-sys-makeFbylst (filename strlst / f n)
    (setq f (open filename "w"))
    (foreach n strlst
      (if (eq (type n) 'STR)
    (write-line n f)
    (write-line (vl-princ-to-string n) f)
    )
      )
    (close f)
    filename
    )
(defun do_bt1    ()
    (setq en (ssget":e:s"'((0 . "REGION"))))
    (if    en
      (setq *area1* (vla-get-area (vlax-ename->vla-object (ssname en 0)))
      area3   (rtos (/ *area1* (atof *area2*)) 2 6)
      *area1* (rtos *area1* 2 3)
      )
      )
    )
(defun do_bt2    ()
    (setq en (ssget":e:s" '((0 . "REGION"))))
    (if    en
      (setq *area2* (vla-get-area (vlax-ename->vla-object (ssname en 0)))
      area3   (rtos (/ (atof *area1*) *area2*) 2 6)
      *area2* (rtos *area2* 2 3)
      )
      )
    )
(setq    dcllst   (list
         "ExtrusionRatio:dialog{label=\"ExtrusionRatio\";"
         ":row{:edit_box{key=\"eb1\";label=\"锭坯截面积(mm^2):\";}"
         ":button{key=\"bt1\";label = \"拾取面域>\";}}"
         ":row{:edit_box{key=\"eb2\";label=\"型材截面积(mm^2):\";}"
         ":button{key=\"bt2\";label = \"拾取面域>\";}}"
         ":row{:edit_box{key=\"eb3\";label=\"挤压比:\";}ok_cancel;}}")
    tmpf   (xty-sys-makeFbylst
         (vl-filename-mktemp nil nil ".dcl")
         dcllst
         )
    dcl_id   (load_dialog tmpf)
    *area1*   (if (not *area1*)
         "201."
         *area1*
         )
    *area2*   (if (not *area2*)
         "101."
         *area2*
         )
    area3   (rtos (/ (atof *area1*) (atof *area2*)) 2 6)
    callback 2
    )
(vl-file-delete tmpf)
(while (> callback 1)
    (new_dialog "ExtrusionRatio" dcl_id)
    (set_tile "eb1" *area1*)
    (set_tile "eb2" *area2*)
    (set_tile "eb3" area3)
    (action_tile "bt1" "(done_dialog 2)")
    (action_tile "bt2" "(done_dialog 3)")
    (setq callback (start_dialog))
    (cond ((= 2 callback) (do_bt1))
      ((= 3 callback) (do_bt2))
      )
    )
(unload_dialog dcl_id)
)



lzg8877 发表于 2022-4-9 08:05:01

谢了,夏生,效果不错,谢谢,我更需要的是用半径算重量,再除型材重量!

Linqu 发表于 2022-4-9 10:19:20

夏生生 发表于 2022-4-8 10:40
大概是这么个意思,根据自己需求去改吧

您好大佬 您的这个插件锭胚截面积能不能改成直接输入棒径 就可以计算

夏生生 发表于 2022-4-9 22:05:05

本帖最后由 夏生生 于 2022-4-9 22:08 编辑

lzg8877 发表于 2022-4-9 08:05
谢了,夏生,效果不错,谢谢,我更需要的是用半径算重量,再除型材重量!
稍微改一下就是了
(defun c:tt (/               xty-sys-makeFbylst         do_bt1
             do_bt2         area4             callback         dcllst
             dcl_id         en             tmpf
            )
(defun xty-sys-makeFbylst (filename strlst / f n)
    (setq f (open filename "w"))
    (foreach n strlst
      (if (eq (type n) 'STR)
      (write-line n f)
      (write-line (vl-princ-to-string n) f)
      )
    )
    (close f)
    filename
)
(defun do_bt1      ()
    (setq en (ssget ":e:s"'((0 . "*text"))))
    (if      en
      (setq *area3* (vla-get-textstring (vlax-ename->vla-object (ssname en 0)))
            area4   (rtos (/(* 0.25 (atof *area2*)(atof *area2*)(atof *area1*) pi)(atof *area3*))2 6)
      )
    )
)
(defun do_bt2 ()
(setq      *area1*      (get_tile "eb1")
      *area2*      (get_tile "eb2")
      *area3*      (get_tile "eb3")
      area4   (rtos (/(* 0.25 (atof *area2*)(atof *area2*)(atof *area1*) pi)(atof *area3*))2 6)
)
(set_tile "eb4"area4)
)
(setq      dcllst         (list
                   "ExtrusionRatio:dialog{label=\"ExtrusionRatio\";"
                   ":row{:edit_box{key=\"eb1\";label=\"容重(g/mm^3):\";}"
                   ":edit_box{key=\"eb2\";label=\"直径(mm):\";}}"
                   ":row{:edit_box{key=\"eb3\";label=\"型材质量(g):\";}"
                   ":button{key=\"bt1\";label = \"拾取文字>\";}}"
                   ":row{:edit_box{key=\"eb4\";label=\"挤压比:\";}:button{key=\"bt2\";label = \"计算\";}ok_only;}}")
      tmpf         (xty-sys-makeFbylst
                   (vl-filename-mktemp nil nil ".dcl")
                   dcllst
               )
      dcl_id         (load_dialog tmpf)
      *area1*         (if (not *area1*)
                   "0.00273"
                   *area1*
               )
      *area2*         (if (not *area2*)
                   "120."
                   *area2*
               )
      *area3*         (if (not *area3*)
                   "1.389"
                   *area3*
               )
      area4(rtos (/(* 0.25 (atof *area2*)(atof *area2*)(atof *area1*) pi)(atof *area3*))2 6)
      callback 2
)
(vl-file-delete tmpf)
(while (> callback 1)
    (new_dialog "ExtrusionRatio" dcl_id)
    (set_tile "eb1" *area1*)
    (set_tile "eb2" *area2*)
    (set_tile "eb3" *area3*)
    (set_tile "eb4" area4)
    (action_tile "bt1" "(setq *area1* (get_tile \"eb1\")*area2* (get_tile \"eb2\"))(done_dialog 2)")
    (action_tile "bt2" "(do_bt2)")
    (setq callback (start_dialog))
    (if(= 2 callback)(do_bt1))
)
(unload_dialog dcl_id)
)

可能我的浏览器有问题,lsp在这里

zjjhero3blade 发表于 2022-4-12 10:53:04

楼主这是挤压模具厂的设计吗
页: [1]
查看完整版本: 求个小程序,求挤压比,谢谢