"batch" mode for element creation ?
"batch" mode for element creation ?
(OP)
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 ?
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





RE: "batch" mode for element creation ?
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
RE: "batch" mode for element creation ?
Quando Omni Flunkus Moritati
RE: "batch" mode for element creation ?
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.
Regards,
SN
RE: "batch" mode for element creation ?
2) often they're not the closest nodes.
Quando Omni Flunkus Moritati
RE: "batch" mode for element creation ?
2) I don't know exactly how the nodes are sorted in your model. But it works fine for closest nodes...
RE: "batch" mode for element creation ?
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
RE: "batch" mode for element creation ?
Quando Omni Flunkus Moritati
RE: "batch" mode for element creation ?
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
RE: "batch" mode for element creation ?
Quando Omni Flunkus Moritati
RE: "batch" mode for element creation ?
RE: "batch" mode for element creation ?
Quando Omni Flunkus Moritati
RE: "batch" mode for element creation ?
Seif Eddine Naffoussi, Stress Engineer
www.Innovamech.com
33650 Martillac – France