how to select part.surface in abaqus using python script - python

How do I select the surfaces on part in Abaqus? I have tried:
tubePart.surface(faces = tubePart.faces[4:8],name = 'innerFaces')
but it keeps saying part object has no attribute surface.

Ideally, you should create a new surface by calling Surface() function (not surface()), i.e.
tubePart.Surface(...)
Secondly, there must be side1Faces instead of faces (thanks to agentp for comment). Thus, the final peace of code should look like this:
tubePart.Surface(side1Faces = tubePart.faces[4:8],name = 'innerFaces')

Related

Need help creating a code that instances an object along a surface evenly

I'm pretty new to coding and I need to create a code that generates an object along the normal of a selected geo surface.
Anything to start me on the right path would be appreciated.
I initially tried to use duplicate, but I was told that command instancer is the better option.
def ChainmailSurfaceGenerator():
thing = MC.ls(sl=True)
print thing
if not thing:
MC.error("select a torus")
#create a group for your chainmail*
grp = MC.group(empty=True, name=thing[0] + '_grp#'
#create hierarchy of grouped toruses
MC.polyTorus( radius=1, n = 'chainmail_link')
MC.duplicate('chainmail_link')
#query the direction of UV normals off the face
#lessen the amount of geometry if its too dense
#try it out on a plane surface first
#keep things simple early
#what if chains don't connect perfectly? add a randomizer so that the chains aren't all completely symmetrical
#don't use MC.duplicate; use Instancer
You might not actually need to query the UV direction of the target geometry.
Try looking into the commands for constraints like cmds.normalConstraint or cmds.geometryConstraint. As for the number of objects to make, consider using a for loop in a range of how many objects you want. If you want to apply a random rotation, I would recommend using a group or a locator as an offset for transforming the group around (either with setAttr or xform) so that you can move the group while maintaining the ability to rotate the duplicate in it's y axis. If you go the route of normal constraints, be sure to use the aim flag to point the object up in its y axis! Googling the commands should come up with documentation on what flags to use.

Setting Custom RoI for OpenCV BoundryBox in Python

I'm trying to implement Object Tracker using OpenCV and I'm new to Python. I'll call it from C# code via IronPython. What I'm trying to do, I want to set a custom rectangle as a parameter to Tracker instead of selecting it by mouse.
(Tracker code is the common example you can find on the internet)
Here is the problematic part :
This is how I set and create a rectangle
initBB = cv2.rectangle(frame ,(154, 278),(173,183), (0, 255, 00),1)
This is Tracker's init method
tracker.init(frame, initBB)
and this is the error
SystemError: new style getargs format but argument is not a tuple
If I wanted to use "normal" way, initBB set would be like
initBB = cv2.selectROI("Frame", frame, fromCenter=False,
showCrosshair=False)
I couldn't see which part I'm doing wrong, am I trying to set the wrong type of object to initBB or setting it in wrong way?
Thanks! Have a nice day!
Your error comes from a misunderstanding of what cv2.rectangle does.
It doesn't return a rectangle as you imagine. It is actually a drawing function. It draws the rectangle on the image you pass as argument and returns None.
A rectangle is just a tuple in Python with the following coordinates: (start_col, start_row, width, height). You can create it without using an OpenCV function.

Paraview: Get Points data from Integrate Variables

Using Python to interface with Paraview, I want to get the "Points" data from an integrate variable filter.
I tried the GetArray("Points") but it can't find it even though you can clearly see it in the GUI if you go to spreadsheet view.
My code is below. With the GUI approach I get for Point ID = 0 the array "Points" has three values (0.54475, -1.27142e-18, 4.23808e-19) which makes sense because the default arrow is symmetric in y and z.
Is there any way to get the value 0.54475 inside python?
MWE
#Import Paraview Libraries
#import sys
#sys.path.append('Path\\To\\Paraview\\bin\\Lib\\site-packages')
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# create a new 'Arrow'
arrow1 = Arrow()
# create a new 'Integrate Variables'
integrateVariables1 = IntegrateVariables(Input=arrow1)
pdata = paraview.servermanager.Fetch(integrateVariables1).GetPointData()
print pdata.GetArray("Points") # prints None
You are very close. For all other arrays, you can access the value using the method you have written.
However VTK treats the point coordinates slightly differently, so the code you need for the point coordinates is:
arrow1 = Arrow()
integrateVariables1 = IntegrateVariables(Input=arrow1)
integrated_filter = paraview.servermanager.Fetch(integrateVariables1)
print integrated_filter.GetPoint(0)
This gives me: (0.5447500348091125, -1.2714243711743785e-18, 4.238081064918634e-19)
I would also suggest that you might want to do this in a Python Programmable Filter. Passing the filter from the server back to the client is not the best practice, and it is preferred to do all calculation on the server.

Maya Python - How do I query the selection to check if only polyVerts or different?

I have a bunch of poly vertex components selected. But sometimes users might select something else along with it (a joint, another mesh, etc.). I'm trying to find a way to test against everything selected to verify it is indeed a vertex. But I can't find anything like this.
Is there a python command to do this directly?
It may be useful for your use-case to use filterExpand with the selectionMask flag set to 31 to return just polygon vertex components from everything that has been selected.
Following is a simple sample (with some comments):
Try it out with different kind of objects and components selected.
import maya.cmds as cmds
# Will return EVERYTHING selected
all_selected = cmds.ls(sl=True)
# Will filter out and return just the verts
# from everything selected
just_the_selected_verts = cmds.filterExpand(sm=31)
Check out filterExpand in the docs here.
Not exactly. You can find objects which are ready for component selection with cmds.ls(hl=True). You can find selected object which aren't components with cmds.ls(o=True). That means you can isolate only the component selections indirectly like this:
set (cmds.ls(sl=True, o=False)) - set(cmds.ls(sl=True, o=True))
which makes a set of the whole selection, then one with only the objects, and finally subtracts the second from the first leaving only the component selections (note that will also pass attribute selections if you have those).

change bones position in a armature in blender game engine using python

I am working on real time mapping of model with the user data obtained from Kinect.
I am able to get access to the individual bone using bge.types.BL_ArmatureObject().channels
which give the list of bones. I am not able to change the position bone. I tried to use rotation_euler to give it some rotation but it had no effect. Please tell me how to do it.
Maybe a little late, but for blender >= 2.5 this should do the trick:
# Get the whole bge scene
scene = bge.logic.getCurrentScene()
# Helper vars for convenience
source = scene.objects
# Get the whole Armature
main_arm = source.get('NAME OF YOUR ARMATURE')
main_arm.channels['NAME OF THE BONE YOU WANT TO ROTATE'].joint_rotation[ x, y ,z] # x,y,z = FLOAT VALUE
main_arm.update()
I also wrote this down in an extensive tutorial, starting here: http://www.warp1337.com/content/blender-robotics-part-1-introduction-and-modelling

Categories

Resources