add_card for 'GRID' or 'CTRIA3'

38 views
Skip to first unread message

Thomas Brooks

unread,
Oct 9, 2015, 11:56:33 AM10/9/15
to pyNastran Discuss
I'm trying to add a node to the model and I'm using the code shown below.

new_node=['GRID',next_node,None,new_node_loc[0],new_node_loc[1],new_node_loc[2]]
#where next_node is an int and the rest are floats
model.add_card(new_node,'GRID')

when I try to get position of the new node with

model.nodes[new_node].get_position()

I get an error that implies that there is no coordinate system defined so I've added a line so that the code looks like:

new_node=['GRID',next_node,None,new_node_loc[0],new_node_loc[1],new_node_loc[2]]
model.add_card(new_node,'GRID')
model.nodes[new_node].cp=model.coords[0]

Then when I try to create a new element with this node I use:

new_element=['CTRIA3',next_element,break_element.Pid(),next_node,break_element.nodes[node_num].Nid(),break_element.nodes[0].Nid()]

model.add_card(new_element,'CTRIA3')


This seems to also not properly create the element because the code below gives an error:


model.elements[next_element].Normal()


The error is:


"    positions[i, :] = node.get_position()

AttributeError: 'int' object has no attribute 'get_position'"


And sure enough, when I check model.elements[next_element].nodes I see a list of integers rather than node objects.


I have tried to use node objects in place of the node IDs, but I get a different error shown below:


RuntimeError: field='GRID        1691          -.2475.4286823   -.045\n' is not 16 characters long...rawValue=GRID        1691          -.2475.4286823   -.045


What am I doing wrong?



Thomas


Steven Doyle

unread,
Oct 9, 2015, 12:57:04 PM10/9/15
to pyNastran Discuss
Tom,

You need to cross reference your model after using the `add_card` method by calling:

    model.cross_reference()

The code builds that call into the read_bdf method.


--
You received this message because you are subscribed to the Google Groups "pyNastran Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pynastran-disc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas Brooks

unread,
Oct 9, 2015, 1:44:34 PM10/9/15
to pyNastran Discuss
Is there a way to cross reference a model multiple times? Can I cross reference a single element or node with the rest of the model?

Steven Doyle

unread,
Oct 9, 2015, 2:03:09 PM10/9/15
to pyNastran Discuss
You can call:

node = model.nodes[nid]
node.cross_reference(model)

to cross reference a single node/element/etc.

I wouldn't call model.cross_reference() twice though that's on the list (as well as an uncross_reference option).

The general recommendation though is to load everything, cross reference, and then use it.
Reply all
Reply to author
Forward
0 new messages