look for required non sequencial node number from field output data set

  Kiến thức lập trình

I have a field output xydata objects for part named “part_rail_1” from nodes 1 to 50

but i need only few ex. for node 2, 4, 5, 7, 11,18,23,32… that are saved in a node set.

x0 = session.xyDataObjects[‘U:U1 PI: PART_RAIL_1 N: 2’]

x1 = session.xyDataObjects[‘U:U1 PI: PART_RAIL_1 N: 5’]

x2 = session.xyDataObjects[‘U:U1 PI: PART_RAIL_1 N: 7’] …

i like to access those node names to save the output data as an array in python using script

Try: function should work but since it is non-sequential, there is key error at node .

session.xyDataListFromField(odb=odb, outputPosition=NODAL, variable=(('U', 
  NODAL, ((COMPONENT, 'U1'), (COMPONENT, 'U2'), )), ), nodeSets=(
  "SET-PARTRAIL", )) # access in the node set

Nodes_U1 = [0]*50 # initialize nodes

for i in range(50):
    try:
      Nodes_U1[i]  = session.xyDataObjects['U:U1 PI: PART_RAIL_1 N: '+str(1+i)] 
    except:
      Nodes_U1[i]  = session.xyDataObjects['U:U1 PI: PART_RAIL_1 N: '+str(2+i)] 

Any help would be appreciated.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT