乐筑天下

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

[编程交流] 获取字符串(&S)

[复制链接]

4

主题

18

帖子

14

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 16:27:20 | 显示全部楼层
要在放置块之前还是之后设置值?
如果要在放置块之前设置值,代码可能看起来像。。。
 
  1. ; if less than 10
  2.    (if (< (car dwgnum) 10.0)
  3.      (setq newstr2 (strcat dwgname "-D0"  (rtos sheetnum 2 0)))
  4.      (setq newstr2 (strcat dwgname "-D"  (rtos sheetnum 2 0)))
  5.    )

 
您可以在放置块之前定义属性。
使用Kword方法设置attribute1。
使用cond函数设置属性,该函数计算第一个属性。。。
 
如果您想在块已经放置时更改属性,您可以使用下面的Lee Mac函数。。。
  1. (command "_insert" "<BLOCKNAME>" l "1" "1" "" <ATTRIBUTE1> <ATTRIBUTE2>)

 
首先单击块,
向KWORD询问第一个值
将KWORD连接为第二个值。
使用上述函数两次来设置值?
回复

使用道具 举报

76

主题

312

帖子

254

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
390
发表于 2022-7-5 16:30:23 | 显示全部楼层
请阅读代码发布指南,并编辑代码以包含在代码标签中。[NOPARSE]
  1. ;; Set Attribute Value  -  Lee Mac
  2. ;; Sets the value of the first attribute with the given tag found within the block, if present.
  3. ;; blk - [ent] Block (Insert) Entity Name
  4. ;; tag - [str] Attribute TagString
  5. ;; val - [str] Attribute Value
  6. ;; Returns: [str] Attribute value if successful, else nil.
  7. (defun LM:setattributevalue ( blk tag val / enx )
  8.    (if (and (setq blk (entnext blk)) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk))))))
  9.        (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
  10.            (if (entmod (subst (cons 1 val) (assoc 1 (reverse enx)) enx))
  11.                (progn
  12.                    (entupd blk)
  13.                    val
  14.                )
  15.            )
  16.            (LM:setattributevalue blk tag val)
  17.        )
  18.    )
  19. )
=
  1. Your Code Here[/NOPARSE]
回复

使用道具 举报

4

主题

2143

帖子

2197

银币

限制会员

铜币
-24
发表于 2022-7-5 16:34:19 | 显示全部楼层
我的建议如果你有很多选择,激活动态输入
 
  1. Your Code Here

然后您可以单击该值(类似于dcl中的单选按钮)
但请记住在代码结束时还原它。
 
如果插入多个块,只需调用defun
请参阅第3篇文章中的更新
 
例子:
  1. (setvar 'dynmode 1)

 
 
附言:请不要忽视版主的建议,用代码标签编辑你之前的帖子
回复

使用道具 举报

5

主题

956

帖子

963

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 16:37:39 | 显示全部楼层
你好,Hanhphnc,
 
谢谢你帮我走到这一步,我已经合并在一起,Lisp程序似乎几乎工作。
 
下面是我尝试使用命令“-Attedit”更改属性块标记值的lisp,当只有1并且最后一个标记通过使用“L”选择标记进行更改时,它可以正常工作。
 
但是,当我指定块名和标记值时,它失败了:(
 
知道吗?是因为我在指定块名后不能使用“last”吗?
 
  1. (if
  2. (and
  3. (setq Mat1Num1 ([color="blue"]MatNum[/color]))
  4. (setq Mat2Num2 ([color="blue"]MatNum[/color]))
  5. (setq p1 (getpoint "\nSpecify point1 : "))
  6. (setq p2 (getpoint "\nSpecify point2 : "))
  7.      )
  8. (progn
  9. (command "-insert" Mat1Num1 p1 1 1 0 ) [color="green"]; do something[/color]
  10. (command "-insert" Mat2Num2 p2 1 1 0 ) [color="green"]; do something else[/color]
  11. )
  12. )

 
;这是一种用于填充属性列表的activeX方法
[code](定义c:测试2(/lst s obj)[颜色=“绿色”];我们假设您有MAT1NUM1全局变量或设置默认值“ML01”(setq[color=“red”]MAT1NUM1(cond(MAT1NUM1)(“ML01”))(提示“\n选择属性块实体….”)(if(and(setq s(ssget“+:s:E:L”((0。“INSERT”)(66.1)))(setq obj(vlax ename->vla object(ssname s 0)))(progn[color=“green”];documented;(setq lst(vlax safearray->list(variant value([color=“blue”]vla getattributesobj))))[color=“green”];需要转换[color][color=“绿色”];未记录的[(setq lst(vlax invoke obj“[color=“blue”]getattributes[(color]))[color=“green”];李·麦克、塔瓦等经常练习。。两个(mapcar“”((x o)(vla put TextString o x));或vlax put(list[color=“red”][color=“red”]MATNUM1[color=“洋红”]“SECOND”“FOURTH”等);
回复

使用道具 举报

4

主题

18

帖子

14

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 16:41:03 | 显示全部楼层
韩,李和大家好,
 
非常感谢你的帮助。
 
刚刚修改了一点Lisp程序从你们这些家伙如何我需要它,请忍受我一些他们正在使用愚蠢的方法。
 
如果对任何人都有用的话,我很乐意附上这些文件。
 
P、 我们非常欢迎任何进一步的建议
 
材料检测2。图纸
 
[code](defun C:QW1(/i s mat1 Num1)(defun LM:setattributevalue(blk tag val/enx)(if(and(setq blk(entnext blk))(=“ATTRIB”(cdr(assoc 0(setq enx(entget blk)kk))(if(=(strcase tag)(strcase(cdr(assoc 2 enx)))))(if(entmod(subst(cons 1 val)(assoc 1(reverse enx))enx))(progn(entupd blk)val))(LM:setattributevalue blk tag val)))(defun LM:setattributevalue(blk tag val/end enx)(while(and(null end)(setq blk(entnext blk))(=“ATTRIB”(cdr(assoc 0(setq enx(entget blk 107;)))(if(=(strcase tag)(strcase(cdr(assoc 2 enx)))))(if(entmod(subst(cons 1 val)(assoc 1(reverse enx))enx))(progn(entupd blk)(setq end val)))(defun dtr(deg)(*pi(/deg 180.0))(defun rtd(a)(/(*a 180.0)pi))(setq dist 300)(setq Area“BR”)(setq yline 21900)(setq ylineDist 350)(setq ML02“H50MM嵌入式不锈钢踢脚线”)(setq cmde(getvar“cmdecho”))(setq osmde(getvar“osmode”))(setq oldlayer(getvar“CLAYER”))(setq dynmde(getvar“Dynmode”)(setvar“cmdecho 0)(setvar”osmode 0)(setvar“Dynmode 1)(defun matNum(/l i s mat1 Num1)(setq i 1l’(“BL”“CP”“GL”“FA”“FB”“ML”“P”“PL”“SP”“ST”“TL”“WC”“WD”)(重复(长度l)(setq s(cons(strcat(itoa i)”_“(nth(1-i)l)”/)s))(setq i(1+i))(initget 7)(if(and(setq i(getint(getint(1))。strcat“\n索引编号[”(应用“strcat(reverse s))”]?:“”))(
回复

使用道具 举报

5

主题

956

帖子

963

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 16:47:08 | 显示全部楼层
回复

使用道具 举报

4

主题

18

帖子

14

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 16:48:17 | 显示全部楼层
Hi hanhphuc, Lee and everyone,
 
Thanks very much for helping.
 
Just amended a little bit the lisp from you guys to how i need it, please bear with me some of them are using silly methods.
 
I'd love to attache the files if it may be of use to anybody.
 
P.S. Any further advises are very welcome
 
MaterialCodeTest2.dwg
 

[code](defun C:QW1 (/ i s mat1 Num1) (defun LM:setattributevalue ( blk tag val / enx )   (if (and (setq blk (entnext blk)) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk))))))       (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))           (if (entmod (subst (cons 1 val) (assoc 1 (reverse enx)) enx))               (progn                   (entupd blk)                   val               )           )           (LM:setattributevalue blk tag val)       )   )) (defun LM:setattributevalue ( blk tag val / end enx )   (while       (and           (null end)           (setq blk (entnext blk))           (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk)))))       )       (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))           (if (entmod (subst (cons 1 val) (assoc 1 (reverse enx)) enx))               (progn                   (entupd blk)                   (setq end val)               )           )       )   ))(defun dtr ( deg ) (* pi (/ deg 180.0)))(defun rtd (a)(/ (* a 180.0) pi))(setq dist 300)(setq Area "BR")(setq yline 21900)(setq ylineDist 350)(setq ML02 "H50MM RECESSED S/S SKIRTING") (setq cmde (getvar "cmdecho")) (setq osmde (getvar "osmode")) (setq oldlayer (getvar "CLAYER")) (setq dynmde (getvar "Dynmode")) (setvar 'cmdecho 0) (setvar 'osmode 0) (setvar 'dynmode 1) (defun matNum (/ l i s mat1 Num1) (setq        i 1l '("BL" "CP" "GL" "FA"        "FB" "ML" "P" "PL" "SP"        "ST" "TL" "WC"    "WD") ) (repeat (length l)   (setq s (cons (strcat (itoa i) "_" (nth (1- i) l) " / ") s))   (setq i (1+ i)) ) (initget 7) (if   (and     (setq i (getint (strcat "\nIndex number ["                      (apply 'strcat (reverse s))                      "]? : "              )      )     )     (
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-14 13:06 , Processed in 0.838328 second(s), 64 queries .

© 2020-2025 乐筑天下

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