Cadence Skill 论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 15637|回复: 12

[原创] 测量线段角度

[复制链接]
发表于 2016-4-12 16:23:43 | 显示全部楼层 |阅读模式
前端时间发过,由于某个原因,已经找不回来了。再次分享给大家。
allegro好像不能直接测量线段的角度。由于近期发现一些不规则的板子,比如圆形outline。
布局时,也可能需要按任意角度摆放,这就需要涉及到按一定的角度来放置。
所以就简单弄了个工具,如果大家觉得有用,就收藏一下。。。。


  1. axlCmdRegister("line_degree" 'line_degree ?cmdType "interactive")

  2. defun(line_degree ()
  3. let((line slop)
  4.         axlUIConfirm("\307\353\321\241\324\361\320\350\322\252\262\342\301\277\265\304Cline/Line!")
  5.         axlSetFindFilter(?enabled '(noall clinesegs linesegs) ?onButtons        '(noall clinesegs linesegs))
  6.         axlSingleSelectPoint()
  7.         line = car(axlGetSelSet())
  8.         axlClearSelSet()
  9.         when(line        
  10.         axlHighlightObject(line)
  11.         slop = axlLineSlope(line->startEnd)
  12.         if(slop
  13.                 then
  14.                         axlUIConfirm(sprintf(nil "Degree : %.2f" axlRadToDeg(atan(slop))))
  15.                 else
  16.                         axlUIConfirm("Degree : 90.0")
  17.         )
  18.         axlDehighlightObject(line)
  19.         )
  20. )
  21. );end defun
复制代码
其实代码很简单,核心语句就是axlRadToDeg(atan(axlLineSlope(line->startEnd))),axlRadToDeg函数只能在16.6及以上版本使用。

发表于 2016-4-20 23:14:43 | 显示全部楼层
吊,大神,牛牛牛牛牛!!!!!!!!!!!!!
发表于 2016-5-17 13:59:59 来自手机 | 显示全部楼层
加载进去以后输入命令line_degree,提示错误argument must be a symbol or nil
发表于 2018-7-2 16:52:10 | 显示全部楼层
非常好用,很方便,谢谢罗老师~
发表于 2021-4-9 14:54:55 | 显示全部楼层
学习学习,收藏一下
发表于 2021-6-29 09:41:20 | 显示全部楼层
大神,牛牛牛牛牛!!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|网站地图|Cadence Skill 论坛 ( 蜀ICP备13024417号 )

GMT+8, 2024-4-27 07:14 , Processed in 0.166934 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表