在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 621|回复: 5

[求助] 脚本中增加什么语句使之具有attach功能

[复制链接]
发表于 2024-1-12 17:08:02 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
在论坛里下载的添加器件label脚本,label尺寸可以跟随器件本身大小调整,呈现出来的效果很好,不会出现跟器件大小很不协调的情况,瑕不掩瑜的是没有attach吸附功能,大佬们帮忙看看在脚本里添加什么语句增加attach功能,万分感谢!

procedure(addName()
          let((cvId txlayer txjust txorient txfont txheight
               inst_coord inst_name inst_W inst_H instCenX
               instCenY txorigin objName
               )
              cvId = geGetEditCellView()
              txlayer = list("text" "drawing")
              txjust = "centerCenter"
              txorient = "R0"
              txfont  = "roman"
              txheight = 1
              foreach(objName geGetSelSet()
                      when(objName~>objType != "inst" && objName~>objType != "mosaic"
                           geDeselectFig(objName)
                          )
                     )
              inst_coord = listToVector(geGetSelSet()~>bBox)
              inst_name = listToVector(geGetSelSet()~>name)
              i = 0
              foreach( inst_name (geGetSelSet()~>name)
                       inst_W = xCoord(car(cdr(inst_coord))) - xCoord(car(inst_coord))
                       inst_H = yCoord(car(cdr(inst_coord))) - yCoord(car(inst_coord))
                       instCenX = xCoord(car(inst_coord)) + (xCoord(car(cdr(inst_coord))) - xCoord(car(inst_coord))) / 2
                       instCenY = yCoord(car(inst_coord)) + (yCoord(car(cdr(inst_coord))) - yCoord(car(inst_coord))) / 2
                       txorigin = instCenX:instCenY
                       if( inst_W >= inst_H then
                           txorient = "R0"
                           txheight = fix(inst_W * 10%)
                           when(txheight >= inst_H
                                txheight = fix(inst_W * 5%)
                               )
                       else
                           txorient = "R90"
                           txheight = fix(inst_H * 10%)
                           when(txheight >= inst_W
                                txheight = fix(inst_H * 5%)
                               )
                          ) ;if
                       if(txheight == 0 then
                          txheight = 0.5
                         )
                       dbCreateLabel(cvId
                                     txlayer
                                     txorigin
                                     inst_name
                                     txjust
                                     txorient
                                     txfont
                                     txheight
                                     )
                       
                       i++
                      )


              ) ;let
         ) ;procedure
hiSetBindKey("Layout" "<Key>b" "addName()")



发表于 2024-1-12 18:00:41 | 显示全部楼层
dbCreateLabel()赋予一个变量,假设是temp,即temp=dbCreateLabel(...),然后在i++的上一行加上这句:leAttachFig(temp inst_name)
 楼主| 发表于 2024-1-12 19:56:01 | 显示全部楼层


着着着火了 发表于 2024-1-12 18:00
dbCreateLabel()赋予一个变量,假设是temp,即temp=dbCreateLabel(...),然后在i++的上一行加上这句:leAtt ...


大佬,首先感谢你的回复,按照你的提示把语句加进去了,有报数据类型错误的error,针对这个问题尝试解决了一段时间但是无果,还得辛苦你费心指点一下,感谢!增加的语句内容在黄色方框内


                               
登录/注册后可看大图

发表于 2024-1-15 09:07:41 | 显示全部楼层


W1508038 发表于 2024-1-12 19:56
大佬,首先感谢你的回复,按照你的提示把语句加进去了,有报数据类型错误的error,针对这个问题尝试解决 ...


这个error 很明显,就是说你函数的格式不对,去找一下attach 这个函数的用法.
发表于 2024-1-15 10:01:38 | 显示全部楼层


W1508038 发表于 2024-1-12 19:56
大佬,首先感谢你的回复,按照你的提示把语句加进去了,有报数据类型错误的error,针对这个问题尝试解决 ...


大概看了一下你给出的代码,有挺多无用的代码,或者说是想那样写但没写对的代码。
代码中用了太多的geGetSelSet(),虽然主体都能找到,但是没有绑定指定的变量,后续的函数没法通过指针找到这个obj。

在foreach之前把geGetSelSet()指定给某个变量,比如insts,然后用foreach遍历,后面的bBox,name都从这个变量再定义或者用~>操作符取出。

insts=geGetSelSet()
foreach(inst insts
    bBox=inst~>bBox
    name=inst~>name


    ...
    leAttachFig(temp inst)

    ...
发表于 6 小时前 来自手机 | 显示全部楼层
楼主解决了没?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

×

小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-9-20 20:39 , Processed in 0.028277 second(s), 6 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表