乐筑天下

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

[编程交流] Lisp to select cid#

[复制链接]

3

主题

9

帖子

6

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 20:19:55 | 显示全部楼层 |阅读模式
Hi, I am working in Fabrication and am trying to make a lisp that will select all items of a certain cid# (4 and 61) and then run a ctext on them. The lisp is also supposed to run a script at the same time, but that part works fine.
 
This is my code so far...
 
  1. (defun c:etag()(setq ss (ssget))(setvar "pickfirst" 1)(sssetfirst nil ss)(executescript "Elbow Tagger.cod")if item.cid = 4, 61 then(addctext "AMCI-Full-Elbow-Tag")end ifend select)
 
Currently, this lisp will apply the ctext to very part selected. I am only familiar with VB so I was a little lost when trying to tell the lisp to select cid#
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-5 20:55:14 | 显示全部楼层
Welcome to CADTutor.
 
More information is needed; the code you posted includes some sub-functions which aren't defined, and perhaps a sample drawing so others might be able to test their offerings?
 
If you post what you're after in VB, C#, etc. I may be able to help port that down to LISP... Presuming, of course, that the appropriate Properties, and Methods are exposed to LISP (not sure what AMEP Command you're calling in your Script either).
 
Cheers
回复

使用道具 举报

3

主题

9

帖子

6

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 21:20:16 | 显示全部楼层
I'm not sure what you mean by a sample drawing but I can definitely elaborate on the sub functions.
 
"Elbow Tagger.COD" is a script I made in visual basic language to fill in the tag-1, tag-2 and tag-3 fields of sheet metal elbows. I will include its code in the box bellow...
 
  1. select item.cidcase 4dim QUOTE = ascii(34)dim extl = 0dim exts = 0dim exti = item.dim["Top Extension"].numvaluedim exto = item.dim["Bottom Extension"].numvaluedim tag1 = item.customdata[7].valuedim rad = item.dim["Inner Radius"].numvaluedim tag2 = item.customdata[8].valuedim tag3 = item.customdata[9].valueif exti < exto thenexts = extiextl = extoend ifif exti > exto thenexts = extoextl = extiend ifexts = Round((exts), 2)extl = Round((extl), 2)rad = Round((rad), 2)item.customdata[7].value = rad + exts + ""+QUOTE+"" + "R"if extl > 2 thenitem.customdata[8].value = extl + ""+QUOTE+"" + "EXT"end ifif exts > 2 thenitem.customdata[9].value = exts + ""+QUOTE+"" + "EXT"end ifitem.update()        end selectselect item.cidcase 61dim QUOTE = ascii(34)item.customdata[7].value = item.dim["Inner Radius"].numvalue + ""+QUOTE+"" +"R"item.update()end select
 
That part works just fine, but the next bit has been giving me trouble.
 
"AMCI-Full-Elbow-Tag" is a ctext I made which creates a tag with 4 fields. 1 field is for the angle of the elbow and the other 3 fields are for the tag-1, tag-2, and tag-3 fields which the "Elbow Tagger.COD" script fills in.
 
I only want the ctext to apply to items which have a cid identification number of 4 and/or 61 but at present, it effects everything I drag select.
 
I would of loved to do this whole thing in a VB script but people have been telling me that scripts cannot load ctext reports so I am trying to load both my script and my ctext from a lisp.
 
I suppose, if the ctext portion of the lisp were to be in VB, it would probably look something like this....but I am not an experienced programmer so I could be way off.
 
  1. select item.cid      case 4, 61      addctext "AMCI-Full-Elbow-Tag"end select
 
Thanks a lot for offering to help and being so friendly. Some people can be snarky when I ask a beginner question.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-11 09:27 , Processed in 1.149128 second(s), 58 queries .

© 2020-2025 乐筑天下

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