找回密码
 注册
Simdroid-非首页
查看: 185|回复: 8

[二次开发] 求助 请大家帮帮检查下这个程序(已解决)

[复制链接]
发表于 2011-5-19 20:32:26 | 显示全部楼层 |阅读模式 来自 德国
本帖最后由 wanxlxg 于 2011-5-20 20:38 编辑

在学习用abaqus参数化建模,以前没接触过这个 都是用proe画模型,对于编程更是只学过一点入门的c语言。。。归正题,要画一个齿轮,最近研究了下 编了个画渐开线的方程,可是出现了个错误,不知道怎么解决,希望各位高人至指点下


from abaqus import*
from abaqusConstants import*
session.Viewport(name='Viewport: 1', origin=(0.0, 0.0), width=324.555541992188,
    height=204.226654052734)
session.viewports['Viewport: 1'].makeCurrent()
session.viewports['Viewport: 1'].maximize()
from caeModules import *
from driverUtils import executeOnCaeStartup
executeOnCaeStartup()
import math
Mdb()
fields=(('durchmesser:','10'))
rb=getInputs(fields=fields,label='Enter Dimensions:')
Alpha=0
i=1
T=0
s=8
imt=0.05
n=10
while i<=n:
    T=T+imt
    Alpha=T*math.sqrt(s)
    x=rb*(math.cos(Alpha)+Alpha*math.sin(Alpha))
    y=-rb*(math.sin(Alpha)-Alpha*math.cos(Alpha))
    i=i+1
session.viewports['Viewport: 1'].setValues(displayedObject=None)
s = mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=200)
g, v, d, c = s.geometry, s.vertices, s.dimensions, s.constraints
s.sketchOptions.setValues(decimalPlaces=3)
s.setPrimaryObject(option=STANDALONE)
s.Spline(points=(x,y))
s.VerticalConstraint(entity=g[2])

错误提示是:
line 23 ,in <module>    x=rb*(math.cos(Alpha)+Alpha*math.sin(Alpha))
typeError: can't multiply sequence by non-in of type 'float'
发表于 2011-5-19 20:55:45 | 显示全部楼层 来自 山东济南
Simdroid开发平台
rb=getInputs(fields=fields,label='Enter Dimensions:')
这个地方你所定义的rb字符型的,你应该把它转换为浮点型的,可以在这个后面加上一句rb=float(rb)试一下,祝成功




1# wanxlxg

评分

1

查看全部评分

回复 不支持

使用道具 举报

发表于 2011-5-19 21:08:03 | 显示全部楼层 来自 北京
这个是用什么编的?python?怎么运行?
回复 不支持

使用道具 举报

 楼主| 发表于 2011-5-20 15:49:29 | 显示全部楼层 来自 德国
2# marpyuanff

还是不行,说是float()必须是 一个字符串或数字,没明白,我后来把rb直接定义为10了 ,可是后面 画曲线的时候还是出现错误!头疼
回复 不支持

使用道具 举报

 楼主| 发表于 2011-5-20 15:50:13 | 显示全部楼层 来自 德国
3# liuxb

是用python编的,用abaqus运行
回复 不支持

使用道具 举报

发表于 2011-5-20 19:31:25 | 显示全部楼层 来自 山东济南
你的这个脚本我又仔细看了,并运行了一下。不仅仅是那个rb的数据类型有问题,同时你的后面有个地方还得用元组,我改过的地方下面用红色表示,其中最后的这个约束s.VerticalConstraint(entity=g[2]),应该不太对,删去就行。下面的这段程序现在已经可以运行,你可以试一下,不知道是不是你想要的效果
from abaqus import*
from abaqusConstants import*
session.Viewport(name='Viewport: 1', origin=(0.0, 0.0), width=300,height=150)
session.viewports['Viewport: 1'].makeCurrent()
session.viewports['Viewport: 1'].maximize()
from caeModules import *
from driverUtils import executeOnCaeStartup
executeOnCaeStartup()
import math
Mdb()
fields=(('durchmesser:','10'))
rb=getInputs(fields=fields,label='Enter Dimensions:')
rb=float(rb[0])
Alpha=0
i=1
T=0
s=8
imt=0.05
n=10
points=[]
while i<=n:
    T=T+imt
    Alpha=T*math.sqrt(s)
    x=rb*(math.cos(Alpha)+Alpha*math.sin(Alpha))
    y=-rb*(math.sin(Alpha)-Alpha*math.cos(Alpha))
    points.append((x,y))
    i=i+1
session.viewports['Viewport: 1'].setValues(displayedObject=None)
s = mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=200)
g, v, d, c = s.geometry, s.vertices, s.dimensions, s.constraints
s.sketchOptions.setValues(decimalPlaces=3)
s.setPrimaryObject(option=STANDALONE)
s.Spline(points=points)


4# wanxlxg

评分

1

查看全部评分

回复 不支持

使用道具 举报

发表于 2011-5-20 20:24:04 | 显示全部楼层 来自 德国
1# wanxlxg

Wozu?
回复 不支持

使用道具 举报

 楼主| 发表于 2011-5-20 20:34:55 | 显示全部楼层 来自 德国
7# cdstudio

zu meiner SA!哈哈
回复 不支持

使用道具 举报

 楼主| 发表于 2011-5-20 20:37:31 | 显示全部楼层 来自 德国
6# marpyuanff
太感谢了,是这样的,不知道说什么好了哈哈,谢谢
回复 不支持

使用道具 举报

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

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2026-1-7 23:01 , Processed in 0.036324 second(s), 19 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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