flowerrobot 发表于 2022-7-6 14:48:14

选择一个项目

我一辈子都记不住了,我记不起正确的措辞来找到它;(.
 
我只想选择一个项目,这就是pedit的工作原理。
 
 
这是我目前拥有的,但一旦被选中,我希望它继续前进
(setq ss1 (ssget "X" '((0 . "INSERT")(66 . 1))))
 
谢谢你抽出时间

Lee Mac 发表于 2022-7-6 14:55:34

是否需要用户选择项目,如(ssget“X”…)将自动选择项目。
 
如果它确实是来自用户的单个选择,您可以使用以下任一选项:
 

(if (and (setq ent (car (entsel "\nSelect Item: ")))
      (= "INSERT" (cdr (assoc 0 (entget ent))))
      (= 1 (cdr (assoc 66 (entget ent)))))
(progn
;...do stuff...
)
(princ "\nSelected Item Isn't an Attributed Block"))


 

 

(if (setq ss (ssget "_:S" '((0 . "INSERT") (66 . 1))))
(progn
;; do stuff here...
)
(princ "\nNothing Selected"))

flowerrobot 发表于 2022-7-6 15:02:09

谢谢李的回复。
这就是我想要的

(while
(not
(setq ss (ssget "_:S" '((0 . "INSERT") (66 . 1))))
)
)
 
还有,当我烦你的时候。
还有什么替代方案
(setq en (ssname ss1 0))
(setq ed (entget en))
(setq blkn (dxf 2 ed))


很快就会出现这种情况
(= "ITEMBALLOON" blkn)
 
(试图找到正确的块)
 
 
谢谢你抽出时间!

Lee Mac 发表于 2022-7-6 15:14:37

如果您只希望用户选择该特定块,只需将其包括在ssget的过滤器列表中:
 

(while
(not
(setq ss (ssget "_:S" '((0 . "INSERT")(2 . "ITEMBALLOON")(66 . 1))))
)
)

Lee Mac 发表于 2022-7-6 15:19:19

 
但在回答你的问题时:
 

(setq blkn (cdr (assoc 2 (entget (ssname ss1 0)))))

flowerrobot 发表于 2022-7-6 15:24:38

非常感谢!!
 
最后一个问题。
为什么这一点不起作用,它会重复,但不会停止,
(defun c:ct ()
    ;for testing
    ;to find if want to increase or renumber from a selected up
(setq incre (getstring (strcat "\nDo you want to renumber(1,2) or increment (+1,-2)? <" incre "> :")))
    ;works out the choice made
(cond ((= (substr incre 1 1) "+")
(progn
   (setq change 0)
   (setq orgno (atoi (substr incre 2)))
)
)
((= (substr incre 1 1) "-")
(progn
   (setq change 1)
   (setq orgno (atoi (substr incre 2)))
)
)
((<= 1 (atoi incre))
(progn
   (setq change 2)
   (setq orgno (atoi incre))
)
)
)
;this while!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
(while
(progn
   (setq ss1 nil) ;select the block for it to be done to.
(while
   (not
   (setq ss1 (ssget "_:S" '((0 . "INSERT") (66 . 1))))
   )
)
    ;finds its data
(setq en (ssname ss1 0))
(setq ed (entget en))
    ;makes sure its itemballoon
(setq blkn (cdr (assoc 2 ed)))
(cond
   ((= blkn "ITEMBALLOON")
    (progn
      (setq edata (entget en))
      (setq edata (entget (entnext (cdr (assoc -1 edata)))))
    ;gives attibutes current number
      (setq itembubbleorg (atoi (cdr (assoc 1 edata))))
      (rever)
    )
   )
   ((not (= blkn "ITEMBALLOON"))
    (Princ "\nYou Must Select the Item Bubble or masslist block")
)
   )
)
)
)
(defun rever ()   ;0, addes the number to the items one,1 takes it away, 2 changes it to selected one, then every item seleted will add one to that (change 3)   
(cond
   ((= change 0)
    (setq itembubblenew (+ itembubbleorg orgno))
   )
   ((= change 1)
    (setq itembubblenew (- itembubbleorg orgno))
   )
   ((= change 2)
    (progn
      (setq change 3)
      (setq itembubblenew orgno)
    )
   )
   ((= change 3)
    (setq itembubblenew (1+ itembubblenew))
   )
)
    ;creates the number to a string
(setq interitembubblenew (itoa itembubblenew))
    ;inserts it back to the attribute
(setq el (subst (cons 1 interitembubblenew) (assoc 1 edata) edata))
(entmod el)
)


 
 
可能不是函数方法,但需要考虑
 
杰米

jammie 发表于 2022-7-6 15:33:52

我想这是一条捷径:
 
(defun c:ct(/incre change orgno ss1 att newitem)(setq incre(getstring(strcat“\n您想重新编号(1,2)或增量(+1,-2)?:”)(cond((=(substr incre 1 1)”+)(setq change 0 orgno(atoi(substr incre 2)))((=(substr incre 1 1)”-”)(setq change 1 orgno(atoi(substr incre 2)))((

Lee Mac 发表于 2022-7-6 15:39:17

不确定最终目标是什么,但这是我的一个选择。
(defun c:ct(/incre change orgno ss1 att newitem)(或incre(setq incre“+1”))(setq incre(getstring(strcat”\n是否要重新编号(1,2)或增量(+1,-2)?:”)(cond(=(substr incre 1)”+“”(setq change 0 orgno(atoi(substr incre 2)))(=(substr incre 1 1)”-“”)(setq更改1 orgno(atoi(substr增量2)))((

CAB 发表于 2022-7-6 15:47:31

可悲的是,我似乎没有得到任何可行的建议,
杰米,我本来想这么做的,但是“S”的效果是一样的,
谢谢李,我会接受的
出租车,伙计,你的车没法开,试着玩弄它,但不行。
如果看不到它的作用,请放置一个带属性的块,其中第一个属性是一个数字,然后可以为每个选定的块选择将其增加6“+6”或“-6”,或者从任何数字开始重新编号。
我相信阿斯米,有一个非常相似的,但我不想要前缀或苏菲派
 
谢谢你们的帮助!

flowerrobot 发表于 2022-7-6 15:52:32

页: [1]
查看完整版本: 选择一个项目