Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

"batch" mode for element creation ?

Status
Not open for further replies.

rb1957

Aerospace
Apr 15, 2005
16,006
is there an automated way to make a bunch of elements ?

i've got a list of N1 and N2 that i've extracted out of the model and need to make a set of beams. could give them all the same PID. they'd represent rivets between elements modelled at mid-thickness

thoughts ?

Quando Omni Flunkus Moritati
 
Replies continue below

Recommended for you

My immutable answer: API!
Something in the likes of - see below.
This supposes that:
1) you've pre-created your beam property. specify the id in the code. Or use a prop object and select/create a new one.
2) your list N1 - N2 is in a text file in column format, separated by space(s). if not adapt the code
3) how do you orient your beams? nodeID? vector? cf part 2 of code
Be sure to fill in where specified.
Hope this helps,

AP



Sub Main
Dim App As femap.model
Set App = feFemap()

Dim s As String, sAr As Variant
Dim nodes() As Long
Dim el As femap.Elem
Set el = App.feElem


'*** 1) READ FILE
s = GetFilePath("","",,"Select file",0)
If s = "" Then End

'NB: only dim2 is dynamically redim-able in VB
ReDim nodes(1,0)

Open s For Input As #1
While Not EOF(1)
Line Input #1, s
If s ="" Then GoTo SKIPLINE 'skip empty lines

s = Trim(s) 'leading/trailing spaces
While InStr(s," ")<>0 'multiple spaces
s = Replace(s," "," ")
Wend
sAr = Split(s)

'dyamic array which stores N1 - N2
If nodes(0,0)<>0 Then ReDim Preserve nodes(1,UBound(nodes,2)+1)
nodes(0,UBound(nodes,2)) = CLng(sAr(0))
nodes(1,UBound(nodes,2)) = CLng(sAr(1))
SKIPLINE:
Wend
Close #1


'*** 2) CREATE ELEMS
el.type = FET_L_BEAM : el.topology = FTO_LINE2
el.propID = 'FILL IN!! specify propID - could also select it with a prop object...
el.orientID = 'FILL IN!! trick: orient with node or vector...? 0 if vector, nodeID otherwise

Dim v1 As Variant, v2 As Variant 'if orienting with vector

For i = 0 To UBound(nodes,2)
el.Node(0) = nodes(0,i) : el.Node(1) = nodes(1,i)

'if orienting with vector:
App.feCoordOnNode(nodes(0,i),v1)
App.feCoordOnNode(nodes(1,i),v2)
For j = 0 To 2
v1(j) = v2(j)-v1(j) 'vector n1=>n2
Next

'orthogonal vector, should work for orient
If v1(0)<>0 Or v1(1)<> 0 Then
v2(0) = -v1(1) : v2(1) = v1(0) : v2(2) = 0
Else
v2(0) = 1 : v2(1) = 0 : v2(2) = 0
End If
el.orient(0) = v2(0) : el.orient(1) = v2(1) : el.orient(2) = v2(2)
'end part "if orienting with vector"

el.Put(el.NextEmptyID)
Next
End Sub
 
thx for that ... guess i'll have to learn API ... sigh

Quando Omni Flunkus Moritati
 
Why you could not simply use the Mesh / Connect / Closest Link. Femap will ask you to select the first set of nodes then the second.
and you can choose between Rigid, Line elements (beam, spring damper...). A dialog box asking for the orientation vector will appear after hitting OK.
And you are done.
getfile.aspx

Regards,
SN
 
1) that'd be one by one, no?
2) often they're not the closest nodes.

Quando Omni Flunkus Moritati
 
1) No, this is the case for "Multiple" command but if you use the "closest link" and create two separate groups and then choose one group for "generate from" and the second for "generate to" Femap will create all elements instantaneously.
2) I don't know exactly how the nodes are sorted in your model. But it works fine for closest nodes...
 

Here is a gift for you...and for Femap community.

Just enter your elements IDs in one column (there is a button to get the Max Elem ID). Existing Property ID and Node 1 IDs Nodes 2 IDs and your are done.
Then go to Femap to define the orientation vector. I don't have enough time to put it in the Macro...

Like this you would control the creation of these elements.

Regards,
SN
 
 http://files.engineering.com/getfile.aspx?folder=82e58f62-ee0e-4356-8c4f-05bba49476cc&file=Create_C-BEAM_elements.xlsm
maybe i'm missing something (not for the first or last time) but pressing the "create" button got me "compile error in hidden module feuil1".

Quando Omni Flunkus Moritati
 
Ah sorry it is about VBA references.

Here is the macro without Password. Under VBA go to tools / references,
uncheck the Femap version already defined and upload the femap.tlb which is in the current Femap version directory and hit Ok.
Retry and keep me informed.

Regards,
SN
 
 http://files.engineering.com/getfile.aspx?folder=3a172e31-12e6-4ece-a5e0-3e04f460b086&file=Create_C-BEAM_elements.xlsm
you had me at "under VBA" ... don't see it on a ribbon ... incomplete installation ?

Quando Omni Flunkus Moritati
 
Right click on the worksheet name "Creat-C-BEAM" and hit "visualize code" (magnifying glass)and then VBA will appear [smile]
 
thx !

Quando Omni Flunkus Moritati
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor