User login

Navigation

You are here

how can I modeling a random perforation plate?

hamid-moaieri's picture

hi

I'm try to create a plate with random perforations.

my python code:

# -*- coding: mbcs -*-
from part import *
from material import *
from section import *
from assembly import *
from step import *
from interaction import *
from load import *
from mesh import *
from optimization import *
from job import *
from sketch import *
from visualization import *
from connectorBehavior import *

a=100
b=50
t=8

mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=200.0)
mdb.models['Model-1'].sketches['__profile__'].rectangle(point1=(0.0, 0.0),
    point2=(a, b))
mdb.models['Model-1'].Part(dimensionality=THREE_D, name='Part-1', type=
    DEFORMABLE_BODY)
i=0
while i < 20:
        r=7
        x0=100*random.random()
        y0=50*random.random()
        mdb.models['Model-1'].parts['Part-1'].BaseSolidExtrude(depth=t, sketch=
        mdb.models['Model-1'].sketches['__profile__'])
        del mdb.models['Model-1'].sketches['__profile__']
        mdb.models['Model-1'].parts['Part-1'].HoleThruAllFromEdges(diameter=r,
        distance1=x0, distance2=y0, edge1=
        mdb.models['Model-1'].parts['Part-1'].edges[7+2*i], edge2=
        mdb.models['Model-1'].parts['Part-1'].edges[10+2*i], plane=
        mdb.models['Model-1'].parts['Part-1'].faces[4+i], planeSide=SIDE1)
        i=i+1
        #

 

and the errorr :

NameError: name 'random' is not defined

 

 

why? plz

You forgot to import the random module. Just put "import random" somewhere up top and it will fix that error message. Note, it might be better to use "random.uniform(0.0, 100.0)" instead of "100*random.random()".

hamid-moaieri's picture

Dear Mswan

could you please help me to find thats module command pattern and syntax?

The python standard library includes the "random" module. There's no need to look for it, download it, or compile it. It is there in every build of python.

Up at the top of your file you have a ton of import statements. Most of them are like "from XYZ import *". All you need to do is put "import random" somewhere up there with the others (conventionally, standard library modules are imported first).

I would highly suggest actually working through a series of python tutorials. I've heard good things about Codeacademy - try https://www.codecademy.com/tracks/python.

hamid-moaieri's picture

tanx

 

when i cut a circle from a rectabgle face , is its ID changed(for plate"?

if i set a plate in term of :

plt = myModel.Part(name='Plate',
    dimensionality=THREE_D, type=DEFORMABLE_BODY)

 and then holecut of this part, are the plate edges ID changed?

Subscribe to Comments for "how can I modeling a random perforation plate?"

More comments

Syndicate

Subscribe to Syndicate