×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

"batch" mode for element creation ?

"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 ?

Quando Omni Flunkus Moritati

RE: "batch" mode for element creation ?

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

RE: "batch" mode for element creation ?

(OP)
thx for that ... guess i'll have to learn API ... sigh

Quando Omni Flunkus Moritati

RE: "batch" mode for element creation ?

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.

Regards,
SN

RE: "batch" mode for element creation ?

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

Quando Omni Flunkus Moritati

RE: "batch" mode for element creation ?

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...

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 ?

(OP)
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

RE: "batch" mode for element creation ?

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

RE: "batch" mode for element creation ?

(OP)
you had me at "under VBA" ... don't see it on a ribbon ... incomplete installation ?

Quando Omni Flunkus Moritati

RE: "batch" mode for element creation ?

Right click on the worksheet name "Creat-C-BEAM" and hit "visualize code" (magnifying glass)and then VBA will appear smile

RE: "batch" mode for element creation ?

(OP)
thx !

Quando Omni Flunkus Moritati

RE: "batch" mode for element creation ?

You welcome !!

Seif Eddine Naffoussi, Stress Engineer
www.Innovamech.com
33650 Martillac – France

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources