乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 51|回复: 1

[编程交流] 插入块,提示使用p

[复制链接]

2

主题

5

帖子

3

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 08:47:54 | 显示全部楼层 |阅读模式
我正在使用动态块为许多相互关联的零件自动创建2.5d轴铣削刀具路径。
 
我有一个动态块,有6个可见性状态,7个需要用户输入的参数,223个辅助参数和大量的几何约束来将其保持在一起。
 
问题是,即使在我的工作站上(i5 750 OC,16gb ram,ATi 2d卡),插入和使用这个块也很慢。当然,当我将块的后续实例添加到图形中时,延迟问题会恶化。
 
是否有LISP例程可以提示用户插入哪个块,然后提示7个必要参数和所需的可见性状态,在指定点插入块,然后分解并删除所有几何约束?
 
谢谢!
回复

使用道具 举报

2

主题

5

帖子

3

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 09:48:46 | 显示全部楼层
我找了几次后发现了这个。
 
  1. ;;;  Tlindell 2007
  2. ;;;
  3. ;;;  This routine is designed to prompt parameters and attributes when a block is inserted in a drawing.
  4. ;;;  The routine will engage after the insert command, a block is dragged from a toolpalette or the Design Center.
  5. ;;;  The routine turns off normal attribute prompting and issues it's own.  This was to fix certain prompting issues.
  6. ;;;  The routine filters out any parameters that do not show up on the Properties palette.
  7. ;;;
  8. ;;;*******************************************************************
  9. ;;;support functions
  10. (vl-load-com)
  11. (vl-load-reactors)
  12. ;;;*******************************************************************
  13. ;;;callback functions
  14. (defun gp:binsertatts (a b / ss obj objattr nwstr)
  15. (if (or (eq (car b) "EXECUTETOOL") (eq (car b) "DROPGEOM") (eq (car b) "INSERT") (eq (car b) "-INSERT"))
  16.    (setvar "attreq" 0)
  17. )
  18. )
  19. (defun gp:binsertatte (a b / ss->objlist ss obj objattr nwstr objdyn newvalue prmpts cnt dyn dynp)
  20. (defun ss->objlist (ss / cnt objlist)
  21.    (setq cnt (sslength ss))
  22.    (repeat cnt
  23.      (setq objlist (append objlist (list (vlax-ename->vla-object (ssname ss (- cnt 1))))))
  24.      (setq cnt (- cnt 1))
  25.    )
  26.    (setq ss nil)
  27.    objlist
  28. )
  29. (if (or (eq (car b) "EXECUTETOOL") (eq (car b) "DROPGEOM") (eq (car b) "INSERT") (eq (car b) "-INSERT"))
  30.    (progn
  31.      (setq dyn (getvar "dynmode"))
  32.      (setq dynp (getvar "dynprompt"))
  33.      (setvar "dynprompt" 1)
  34.      (setvar "dynmode" 1)
  35.      (setq ss (ssget "L"))
  36.      (setq obj (ss->objlist ss))
  37.      (foreach o obj
  38.        (if (= (cdr (assoc 0 (entget (vlax-vla-object->ename o)))) "INSERT")
  39.          (progn
  40.            (if (= (vla-get-HasAttributes o) :vlax-true)
  41.              (progn
  42.                (setq objattr (vlax-safearray->list (vlax-variant-value (vla-GetAttributes o))))
  43.                (foreach oa objattr
  44.                  (setq oatr oa)
  45.                  (if (= (vla-get-Constant oa) :vlax-false)
  46.                    (progn
  47.                      (setq nwstr (getstring (strcat "\nSpecify " (vla-get-TagString oa) ": <" (vla-get-TextString oa) ">: ")))
  48.                      (if (/= nwstr "") (vla-put-TextString oa nwstr))
  49.                      (setq nwstr nil)
  50.                    )
  51.                  )
  52.                )
  53.              )
  54.            )
  55.            (if (= (vla-get-IsDynamicBlock o) :vlax-true)
  56.              (progn
  57.                (setq objdyn (vlax-safearray->list (vlax-variant-value (vla-GetDynamicBlockProperties o))))
  58.                (foreach od objdyn
  59.                  (if (and (= (vla-get-Show od) :vlax-true) (= (vla-get-ReadOnly od) :vlax-false) (/= (vla-get-PropertyName od) "Origin"))
  60.                    (progn
  61.                      (if (= (vlax-safearray-get-u-bound (vlax-variant-value (vla-get-AllowedValues od)) 1) -1)
  62.                        (progn
  63.                          (if (= (vla-get-Description od) "")
  64.                            (setq prmpts (strcat "\nEnter value for " (vla-get-PropertyName od) ":"))
  65.                            (setq prmpts (strcat "\nEnter value for " (vla-get-Description od) ":"))
  66.                          )
  67.                          (cond
  68.                            ((= (vla-get-UnitsType od) acAngular) (setq newvalue (getorient prmpts)))
  69.                            ((= (vla-get-UnitsType od) acDistance) (setq newvalue (getdist prmpts)))
  70.                            ((= (vla-get-UnitsType od) acArea) (setq newvalue (getreal prmpts)))
  71.                          )
  72.                          (if (/= newvalue nil) (vla-put-Value od (vlax-make-variant newvalue)))
  73.                        )
  74.                        (progn
  75.                          (setq prmpts "[")
  76.                          (setq cnt 1)
  77.                          (foreach pt (vlax-safearray->list (vlax-variant-value (vla-get-AllowedValues od)))
  78.                            (if (= (vla-get-UnitsType od) acNoUnits)
  79.                              (if (numberp (vlax-variant-value pt))
  80.                                (if (= (vlax-variant-value pt) 0)
  81.                                  (setq prmpts (strcat prmpts (itoa cnt) ").NotFlipped "))
  82.                                  (setq prmpts (strcat prmpts (itoa cnt) ").Flipped "))
  83.                                )
  84.                                (setq prmpts (strcat prmpts (itoa cnt) ")." (vl-string-translate "/" "|" (vl-string-translate " " "-" (vlax-variant-value pt))) " "))
  85.                              )
  86.                              (setq prmpts (strcat prmpts (itoa cnt) ")." (vl-string-translate "/" "|" (vl-string-translate " " "-" (rtos (vlax-variant-value pt)))) " "))
  87.                            )
  88.                            (setq cnt (+ cnt 1))
  89.                          )
  90.                          (setq prmpts (strcat (vl-string-right-trim " " prmpts) "]"))
  91.                          (initget 0 (vl-string-trim "[]" prmpts))
  92.                          (if (= (vla-get-Description od) "")
  93.                            (setq newvalue (getkword (strcat "\nEnter value for " (vla-get-PropertyName od) ":" (vl-string-translate " " "/" prmpts))))
  94.                            (setq newvalue (getkword (strcat "\nEnter value for " (vla-get-Description od) ":" (vl-string-translate " " "/" prmpts))))
  95.                          )
  96.                          (if (/= newvalue nil)
  97.                            (progn
  98.                              (setq newvalue (nth (- (atoi (substr newvalue 1 (vl-string-position 41 newvalue))) 1) (vlax-safearray->list (vlax-variant-value (vla-get-AllowedValues od)))))
  99.                              (vla-put-Value od newvalue)
  100.                            )
  101.                          )
  102.                        )
  103.                      )
  104.                    )
  105.                  )
  106.                )
  107.              )
  108.            )
  109.          )
  110.        )
  111.      )
  112.      (setvar "dynmode" dyn)
  113.      (setvar "dynprompt" dynp)
  114.    )
  115. )
  116. (setvar "attreq" 1)
  117. (princ)
  118. )
  119. ;;;*******************************************************************
  120. ;;;reactors
  121. (setq rinsrte (vlr-command-reactor nil '((:vlr-commandEnded . gp:binsertatte))))
  122. (setq rinsrts (vlr-command-reactor nil '((:vlr-commandWillStart . gp:binsertatts))))

 
http://forums.autodesk.com/t5/Dynamic-Blocks/Setting-Parameter-values-at-block-insertion/td-p/3062224
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-7 08:24 , Processed in 0.392738 second(s), 56 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表