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

[二次开发] python如何建立空间桁架

[复制链接]
发表于 2014-1-14 22:08:17 | 显示全部楼层 |阅读模式 来自 湖南益阳
请问大家是如何用python建立空间桁架的?我用了三维空间点连线的方法:p.DatumPointByCoordinate(coords=(xa, ya, 2*za))
p.DatumPointByCoordinate(coords=(xc, yc, 2*zc))
p.DatumPointByCoordinate(coords=(xc, yc, (za+zb)))
p.DatumPointByCoordinate(coords=(xc, yc, (za+zl)))
p.DatumPointByCoordinate(coords=(xc, yc, (za-zl)))
p.DatumPointByCoordinate(coords=(xc, yc, (za-zb)))
p.DatumPointByCoordinate(coords=(xb, yb, (za+zb)))
p.DatumPointByCoordinate(coords=(xb, yb, (za-zb)))

a = mdb.models['Model-1'].rootAssembly
p = mdb.models['Model-1'].parts['Axingjia']
b=a.Instance(name='Axingjia-1', part=p, dependent=ON)
v1,d1 = p.vertices,p.datums
其中“v1,d1 = p.vertices,p.datums”,我如何确切的指导我建立的空间点的编号,或者如何按照我想要的顺序把上面这些点连接起来?findAt命令可以用于p.vertices,但是不知道怎么找空间点,盼望回复,先谢过了!
发表于 2014-1-15 08:04:57 | 显示全部楼层 来自 天津
Simdroid开发平台
findAt好象是不能用于DatumPoint的。一般用Sketch中的Line建立形状,然后再建立Part
回复 不支持

使用道具 举报

 楼主| 发表于 2014-1-15 20:58:27 | 显示全部楼层 来自 天津
cl_qiu 发表于 2014-1-15 08:04
findAt好象是不能用于DatumPoint的。一般用Sketch中的Line建立形状,然后再建立Part ...

由于是空间的,如果用sketch中的line,要建立草绘平面,而且中间的连线也很不方便,能不能通过空间点的坐标来实现啊?
回复 不支持

使用道具 举报

发表于 2014-1-16 15:15:19 | 显示全部楼层 来自 天津
本帖最后由 cl_qiu 于 2014-1-18 20:23 编辑

楼主自己已经找到办法了,见6楼。

评分

1

查看全部评分

回复 不支持

使用道具 举报

 楼主| 发表于 2014-1-18 18:45:18 | 显示全部楼层 来自 河北
cl_qiu 发表于 2014-1-16 15:15
DatumPoints是不能当做Vertices来用的,所以不能通过DatumPoint来建立桁架。我没有实际做过空间桁架的算例 ...

谢谢回复,我已经用DatumPoints的方法解决了,主要是要进行参数化建模,所以肯定是要用空间坐标来解决的。
回复 不支持

使用道具 举报

发表于 2014-1-23 21:59:27 | 显示全部楼层 来自 江苏苏州
p是一个part

p.WirePolyLine(points=xyz, mergeWire=OFF, meshable=ON)



def boomCreate(model,pipeLine):   
    if pipeLine[0][12]==1:
            boomName='mainBoom'
    elif pipeLine[0][12]==2:
        boomName='jib'        
    elif pipeLine[0][12]==3:
        boomName='frontMast'      
    elif pipeLine[0][12]==4:
        boomName='rearMast'      
    elif pipeLine[0][12]==5:
        boomName='superMast'
    p=model.Part(name=boomName)
    sec=pipeLine[0][15]   
    pipeType=pipeLine[0][11]
    startRow=0
    n=len(pipeLine)
    nn=0
##    t0=time.time()
    print boomName+' start creating'
    for k in range(n):
        t=pipeLine[k]
        if sec!=t[15] or  pipeType!=t[11]:
            endRow=k  
            xyz=[]        
            midPoint=[]     
            for line in pipeLine[startRow:endRow]:
                    x1=line [0:3]           
                    x2=line [3:6]                        
                    xyz.append((x1,x2))
                    midPoint.append(line [16:19])
            pipeSet=p.WirePolyLine(points=xyz, mergeWire=OFF, meshable=ON)
            setName=p.name+ '_'+str(int(pipeType))  +'_sec_'+str(int(sec))
            secName='sec-'+str(int(sec))
            f=findEdge(p,midPoint,setName)
            
##            if not (len(f.edges)== len(midPoint)):
##                print p.name,len(midPoint),len(f.edges),'----section line  numer error, sec ',sec,' ,pipeType---' ,pipeType
##            else:
##                print p.name,len(midPoint),len(f.edges),'----section line  ',sec,' ,pipeType---' ,pipeType
            p.SectionAssignment(region=f, sectionName=secName, offset=0.0,
                offsetType=MIDDLE_SURFACE, offsetField='',
                thicknessAssignment=FROM_SECTION)
            startRow=k
            sec=t[15]            
            pipeType=t[11]            
            
        
    xyz=[]
    midPoint=[]
    for line in pipeLine[startRow:]:
            x1=line [0:3]           
            x2=line [3:6]                        
            xyz.append((x1,x2))  
            midPoint.append(line [16:19])
            pipeSet=p.WirePolyLine(points=xyz, mergeWire=OFF, meshable=ON)
    setName=p.name+ '_'+str(int(line[11]))  +'_sec_'+str(int(line[15]))
    secName='sec-'+str(int(line[15]))
   
    f=findEdge(p,midPoint,setName)  
   
    if not (len(f.edges)== len(midPoint)):
                print p.name,len(midPoint),len(f.edges),'----section line  numer error, sec ',sec,' ,pipeType---' ,line[11]
    else:
                print p.name,len(midPoint),len(f.edges),'----section line  ',sec,' ,pipeType---' ,pipeType
            
            
    p.SectionAssignment(region=f, sectionName=secName, offset=0.0,
        offsetType=MIDDLE_SURFACE, offsetField='',
        thicknessAssignment=FROM_SECTION)
   

    edges = p.edges
    if not (len(edges)==len(pipeLine)):
               print p.name,'--num error,pipeLine--',len(pipeLine),'  ,edges---',len(edges)
    region=regionToolset.Region(edges=edges)
    p.assignBeamSectionOrientation(region=region, method=N1_COSINES, n1=(0.0, 1.0,  -1.0))
    p.seedPart(size=0.6, deviationFactor=0.1, minSizeFactor=0.1)   
    p.generateMesh()
##    t1=time.time()
##    ## print boomName,'generateMesh',t1-t0
##    t0=time.time()
## chords  and  lattices
    xyz=[ line[16:19] for line in pipeLine if line[11]==1]
    if len(xyz):
        s2=findEdge(p,xyz,'chords')
        eAll=[]
        for ed in s2.edges:  
            es=ed.getElements()
            if len(es)>1:
                 e=es[1]
            else:
                    e=es[0]
            eAll.append(e.label)
        s=p.elements.sequenceFromLabels(eAll)        
        p.Set(name='chordsElement',elements=s)
   
    xyz=[ line[16:19] for line in pipeLine if line[11]==2]
    if len(xyz):        
        s2=findEdge(p,xyz,'lattices')
        eAll=[]
        for ed in s2.edges:  
            es=ed.getElements()
            if len(es)>1:
                 e=es[1]
            else:
                 e=es[0]
            eAll.append(e.label)
        s=p.elements.sequenceFromLabels(eAll)        
        p.Set(name='latticesElement',elements=s)
    print boomName+' start created'
回复 不支持

使用道具 举报

发表于 2014-3-19 10:40:58 | 显示全部楼层 来自 重庆
楼主可否把解决方法贴出来 非常感谢
回复 不支持

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-3-29 06:15 , Processed in 0.040114 second(s), 15 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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