快捷导航 上传作品

[snap] grip 计算角度

[复制链接]
梅雷工具箱发表于 2015-6-25 10:28:50 | 显示全部楼层 |阅读模式
计算角度


gripsw / declrv  
entity / pt(2),ln
number / a,x,y,z,resp


l10:
gpos/'梅雷提示!请选择参考点。',x,y,z,resp
jump/l10:,end:,,,resp

ln=line/x,y,0,0

$$点到圆心的角度(0-359)(360=0)
ifthen/x==0 or y==0
if/x==0 and y>0,a=90
if/x==0 and y<0,a=270
if/y==0 and x>0,a=0
if/y==0 and x<0,a=180
else
a=atanf(absf(y)/absf(x))
if/x>0 and y<0,a=360-a
if/x<0 and y<0,a=180+a
if/x<0 and y>0,a=180-a
endif

print/'点到圆心的角度'
print/a

end:
halt
Grip程序入门第1课

创建一个简单的 Grip程序:① 创建可编译的*.grs文件在C盘 新建记事本文件 输入以下内容messg/'你好grip'
Halt
关闭并保存,记事本重新命名为  mei.grs②编译 mei.grs 生成 mei.gri 连接 生成 mei.grx在C盘 新建记事本文件 输入以下内容

SET grsfile=mei
SET DIR=%cd%
if exist %DIR%\%grsfile%.grx (goto run) else (goto grx)
:grx
if exist %DIR%\%grsfile%.gri (goto link) else (goto gri)
:gri
if exist %DIR%\%grsfile%.grs (goto compile) else (goto grs)

:compile
call "%UGII_ROOT_DIR%"\gripbatch.bat -c -e -dev:%DIR% %grsfile%.grs -l -e
exit

:link
call "%UGII_ROOT_DIR%"\gripbatch.bat -l -e -dev:%DIR% %grsfile%.gri
exit

:run
del %DIR%\%grsfile%.gri
exit

:grs
echo no
pause

关闭并保存,记事本重新命名为  mei.bat

然后双击 mei.bat 你会看到 C盘多出 一个 mei.gri 文件
和一个 mei.grx文件
说明:
mei.grs 为Grip源代码文件mei.gri 为Grip编译文件出现grx后可以删除gri文件mei.grx 为Grip连接文件才是UG可调用文件

③在ug上运行这个程序
  运行ug
  快捷键 Ctrl + G 找到 C:\mei.grx  确定

看看效果把。



























_____________________________________________________________________________ _

中磊UG二次开发教程 梅雷著 qq1821117007
学UG就上UG网 http://www.9sug.com/
就上UG网淘宝直营店
回复

使用道具 评分 举报

您需要登录后才可以回帖 登录 | 注册UG网

本版积分规则