×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Collection for surfaces with python

Collection for surfaces with python

Collection for surfaces with python

(OP)
I am looking to combine surfaces using python but I can't seem to simply add them like I would for faces and cells to create a region. I can use SurfaceByBoolean but I can't find any way around adding each surface manually. Since the number of parts vary, the number of surfaces vary and using findAt at the assembly level would be too tedious and I would like to be able to use the surface created in the part level, then loop through and add these all to the boolean. I am thinking there must be an easier way to combine surfaces but currently haven't had much luck.

Any ideas would be much appreciated.
Cheers.

RE: Collection for surfaces with python

Just collect them in a list and use that list as tuple afterwards.

Here is a similar example at assembly level.

CODE -->

from abaqus import *
from abaqusConstants import *
from caeModules import *

a = mdb.models['Model-1'].rootAssembly

all_surfs = []
for i in mdb.models['Model-1'].rootAssembly.surfaces.keys():
	all_surfs.append(a.surfaces[i])

a.SurfaceByBoolean(name='Surf-merge', surfaces=tuple(all_surfs)) 

RE: Collection for surfaces with python

(OP)
Thanks, worked well using the tuple. For another case, if I choose to use getClosest instead of findAt, then I get a dictionary object which I can convert to a list of just the faces (e.g. tempList=[tempDict[0][0],tempDict[1][0],.. etc) but when I use the surface method I can't seem to use the tuple approach to do the same thing. Does this work differently? The nice part of findAt is that it returns a sequence, even for a single selection, so the results can be added directly. Is there a way to get a type sequence or is this really stored as a mask?

CODE --> Python

region=a.Surface(side1Faces=tuple(tempList), name='Surf') 

This returns feature creation failed, no additional information. I have check the input is a tuple of the required faces.

RE: Collection for surfaces with python

Check that each entry of this list is referenced the way it is required. So print the entries of the list in my example and check if the printout in your example is similar.

RE: Collection for surfaces with python

(OP)
I have the SurfaceByBoolean working, similar to your example. However, I also need to create a surface from faces but I think I will need to manually create a sequence since I am not using findAt. I have checked the references for my faces and they seem to be identical to the output created by Abaqus (i.e. the coordinates are not included, only the face key), the only difference that I can see is that one is a sequence of faces and the other is a tuple of faces.

I don't have access to check yours now but isn't it a slightly different example?

RE: Collection for surfaces with python

(OP)
I did have a look at yours again and it is a list of named surfaces. This is the same as I used for the boolean and it works fine.

To create a surface from faces with Abaqus it is a sequence of face IDs, which is the same as what I am extracting from the dictionary object getClosest. I have checked the manual and my inputs many times and it appears to be correct, the only thing that is different is the type 'sequence' which I don't have. I can't really find any documentation on manually creating a sequence, but hopefully there is a simpler approach.

In the interim, I calculated the precise points on my curved geometry and used findAt without any issues. Would still be good to get the other methods working though.

Thanks for the assistance.

RE: Collection for surfaces with python

I'm not sure I understand the problem you have. Just take the output of getClosest(), create a surface with that and repeat+merge when you have more than one.

Here is an example with three coordinates/surfaces on a simple block:

CODE -->

from abaqus import *
from abaqusConstants import *
from caeModules import *

coord1 = (10.0,0.1,15.0)
coord2 = (10.0,-2.0,21.0)
coord3 = (14.0,-2.0,15.0)


p = mdb.models['Model-1'].parts['block']
f = p.faces
s1 = f.getClosest(coordinates=(coord1,))
s2 = f.getClosest(coordinates=(coord2,))
s3 = f.getClosest(coordinates=(coord3,))

surf1 = f[s1[0][0].index:s1[0][0].index+1]
p.Surface(side1Faces=surf1, name='Surf-coord1')

surf2 = f[s2[0][0].index:s2[0][0].index+1]
p.Surface(side1Faces=surf2, name='Surf-coord2')

surf3 = f[s3[0][0].index:s3[0][0].index+1]
p.Surface(side1Faces=surf3, name='Surf-coord3')

"""
# check coordinates with datum points
p.DatumPointByCoordinate(coords=coord1)
p.DatumPointByCoordinate(coords=coord2)
p.DatumPointByCoordinate(coords=coord3)
"""

all_surfs = []
for i in p.surfaces.keys():
	all_surfs.append(p.surfaces[i])

p.SurfaceByBoolean(name='Surf-merge', surfaces=tuple(all_surfs)) 

RE: Collection for surfaces with python

(OP)
Thanks, as I thought the issue was converting the output to a sequence per your code below. I couldn't find anything in general python or Abaqus documentation about this. Much appreciated.

CODE -->

f[s1[0][0].index:s1[0][0].index+1] 

The below is the application for an assembly. Last question, if you want the full dictionary (s in example below) converted to a sequence, and assuming the number of items are variable or impractical to list one at a time, could the lines creating surf1, surf2 and surf3 be simplified to create one variable containing the full sequence surf1+surf2+surf3?

CODE -->

coord1 = (10.0,0.1,15.0)
coord2 = (10.0,-2.0,21.0)
coord3 = (14.0,-2.0,15.0)

a = mdb.models['Model-1'].rootAssembly
f = a.instances['Part-1'].faces
s = f.getClosest(coordinates=(coord1, coord2, coord3, ))

surf1 = f[s[0][0].index:s[0][0].index+1]
surf2 = f[s[1][0].index:s[1][0].index+1]
surf3 = f[s[2][0].index:s[2][0].index+1]
a.Surface(side1Faces=surf1+surf2+surf3, name='Surf-New') 

RE: Collection for surfaces with python

You should change the way A/CAE reports the geometry in the .rpy. This allows to see directly the way the indexes are used. Enter those commands in the CLI to change the reporting. Or use them in an Abaqus environment variable to have it always active. But it will reduce performance a bit.

CODE -->

session.journalOptions.replayGeometry
session.journalOptions.setValues(replayGeometry=INDEX) 


It is not hard to make the script flexible for any number of coordinates. Below is my previous example adopted to this.
Use the CLI to develop the next steps of a script. Use print and type() to get information and TAB to check the next options in the Abaqus objects.

CODE -->

from abaqus import *
from abaqusConstants import *
from caeModules import *

mycoords = (
(10.0,0.1,15.0),
(10.0,-2.0,21.0),
(14.0,-2.0,15.0))


p = mdb.models['Model-1'].parts['block']
f = p.faces
s = f.getClosest(coordinates=mycoords)
#print s

for a,i in enumerate(s.values()):
	surfx = f[i[0].index:i[0].index+1]
	p.Surface(side1Faces=surfx, name='Surf-'+str(a+1))


"""
# check coordinates with datum points
for i in mycoords:
	p.DatumPointByCoordinate(coords=i)
"""

all_surfs = []
for i in p.surfaces.keys():
	all_surfs.append(p.surfaces[i])

p.SurfaceByBoolean(name='Surf-merge', surfaces=tuple(all_surfs)) 

RE: Collection for surfaces with python

(OP)
I was using the CLI to work though it but had set the journal to coords not index. Thanks for the assistance.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

eBook - Manufacturing the Cars of Tomorrow
In this ebook, we'll explore how additive manufacturing is going to transform the way cars are made. This includes commentary from thought leaders such as Ford's CTO, Ken Washington, Customer case studies of ways 3D printing is being used today, and a variety of part examples where 3D printing is already impacting how automobiles are made. Download Now
White Paper - Smart Manufacturing for Semiconductor
New technologies and approaches present great opportunities for semiconductor manufacturers to achieve high levels of innovation, yield and improvement. This white paper explores some of these cutting-edge technologies and how they can be applied effectively in the semiconductor industry. Read about how Smart Manufacturing is transforming the semiconductor industry. Download Now
White Paper - Analysis and Simulation in Aircraft Structure Certification
Organizations using simulation and analysis tools effectively see the benefits in their ability to achieve certification faster and with drastically less total cost than those who do not maximize these tools. Read this White Paper to learn about how digital tools such as analysis and simulation help in aircraft structure certification. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close