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!

Femap - API Programming - feCoordTransform

Status
Not open for further replies.

francan

Industrial
Mar 17, 2011
2
Hello everyone,

I try to use feCoordTransform command to transform output vector from basic CSys to another Csys.
I use like this:

rc=App.feCoordTransform(0,center(),userCsys.ID,newCenter())

where:
0: ID of basic rectangular CSys
center(): table with 3 values (x,y,z)
userCsys.ID: ID of the new CSys (enter by the user)
newCenter(): table where I want results of the transformation

Everything in declaration seems good but I have an error about the 4th parameter (newCenter())

Somebody could help me please?

Francan from France
 
Replies continue below

Recommended for you

Dear francan,

I have an example that can help you understanding the transformation command in Femap (output, coord...) Take a look at it and try to modify it to obtain what you need. I will drop it here, may be someone else will need it ;)

(j'en vois pas souvent des français sur ce forum, ça veut dire que Femap devient de plus en plus connu en France)

Regards,


'Macro Transform CBUSH Force Output
'Useful when displaying arrows for CBUSH forces
'FEMAP does not properly orient CBUSH output => transform CBUSH output to CSys0 for example

Sub Main
Dim App As femap.model
Set App = feFemap()
App.feAppMessage(FCM_ERROR,"Macro Transform CBUSH Force Output")

Dim osSet As femap.Set
Dim os As femap.OutputSet, ov As femap.Output
Dim cs As femap.CSys, delCSSet As femap.Set
Dim el As femap.Elem, elSet As femap.Set, BUSHset As femap.Set, pr As femap.Prop

Dim l1 As Long, d1 As Double, vec1(2) As Double
Dim var1 As Variant, var2 As Variant, var3 As Variant
Dim elID As Variant, csID As Long
Dim orientID() As Long, elNode0() As Double
Dim outX As Variant, outY As Variant, outZ As Variant, momentFlag As Boolean

Set osSet = App.feSet
Set os = App.feOutputSet
Set ov = App.feOutput
Set cs = App.feCSys
Set delCSSet = App.feSet
Set el = App.feElem
Set elSet = App.feSet
Set BUSHset = App.feSet
Set pr = App.feProp


'0) user input
If osSet.SelectMultiID(FT_OUT_CASE,1,"Select OutputSets") = FE_CANCEL Then End

BUSHset.AddRule(FET_L_SPRING,FGD_ELEM_BYTYPE)
If BUSHset.Count = 0 Then End

If elSet.Select(FT_ELEM,True,"Select elements (selection will be filtered for CBUSH)") = FE_CANCEL Then End
elSet.RemoveNotCommon(BUSHset.ID)
If elSet.Count = 0 Then End

If cs.SelectID("Specify transformation CSys") = FE_CANCEL Then End
csID = cs.ID


'1) retrieve CBUSH output Csys
os.Get(osSet.First)
Set ov = os.Vector(3774)
ov.GetOutputListAtSet(elSet.ID,Null,outX)

ReDim orientID(elSet.Count-1)
ReDim elNode0(elSet.Count-1,2) : l1=0

While el.NextInSet(elSet.ID)
pr.Get(el.propID)

'keep node0 coords (useful if transformation CSys is not rectangular)
App.feCoordOnNode(el.Node(0),var1)
elNode0(l1,0) = var1(0) : elNode0(l1,1) = var1(1) : elNode0(l1,2) = var1(2)

If pr.flag(0) = True Then 'coincident nodes => orient with CSys in property
orientID(l1) = pr.refCS

Else
'NB: nodes should not be coincident (NASTRAN fatal)
App.feCoordOnNode(el.Node(1),var2)

cs.Put(cs.NextEmptyID)
If el.orient(0) <> 0 Or el.orient(1) <> 0 Or el.orient(2) <> 0 Then 'orient wih vector
vec1(0) = var1(0)+el.orient(0) : vec1(1) = var1(1)+el.orient(1) : vec1(2) = var1(2)+el.orient(2) 'in CSys 0 in FEMAP
cs.XYPoints(var1,var2,vec1)

ElseIf el.orientID <> 0 Then 'orient wih node
App.feCoordOnNode(el.orientID,var3)
cs.XYPoints(var1,var2,var3)
End If

cs.Put(cs.ID)
orientID(l1) = cs.ID : delCSSet.Add(cs.ID)
End If

l1 = l1+1
Wend


'2) transform output
elSet.GetArray(l1,elID)
os.Reset : osSet.Reset
While os.NextInSet(osSet.ID)
MOMENTLOOP:
Set ov = Null
Set ov = App.feOutput
Set ov = os.Vector(3774-momentFlag*3)
ov.GetOutputListAtSet(elSet.ID,Null,outX)

Set ov = Null
Set ov = App.feOutput
Set ov = os.Vector(3775-momentFlag*3)
ov.GetOutputListAtSet(elSet.ID,Null,outY)

Set ov = Null
Set ov = App.feOutput
Set ov = os.Vector(3776-momentFlag*3)
ov.GetOutputListAtSet(elSet.ID,Null,outZ)

ReDim var1(2) As Double
For i = 0 To UBound(elID)
vec1(0) = outX(i) : vec1(1) = outY(i) : vec1(2) = outZ(i)
var1(0) = elNode0(i,0) : var1(1) = elNode0(i,1) : var1(2) = elNode0(i,2)

App.feVectorTransform(orientID(i),var1,vec1,csID,var2)

outX(i) = var2(0) : outY(i) = var2(1) : outZ(i) = var2(2)
Next i

Set ov = Null
Set ov = App.feOutput
ov.InitScalarAtElem(os.ID,9003774-momentFlag*3,"Macro Transf to CSys" & CStr(csID) & " - Bush X " & IIf(momentFlag=False,"Force","Moment"),FOT_FORCE,False)
ov.PutScalarAtElem(UBound(elID)+1,elID,outX)
ov.Put(ov.ID)

Set ov = Null
Set ov = App.feOutput
ov.InitScalarAtElem(os.ID,9003775-momentFlag*3,"Macro Transf to CSys" & CStr(csID) & " - Bush Y "& IIf(momentFlag=False,"Force","Moment"),FOT_FORCE,False)
ov.PutScalarAtElem(UBound(elID)+1,elID,outY)
ov.Put(ov.ID)

Set ov = Null
Set ov = App.feOutput
ov.InitScalarAtElem(os.ID,9003776-momentFlag*3,"Macro Transf to CSys" & CStr(csID) & " - Bush Z "& IIf(momentFlag=False,"Force","Moment"),FOT_FORCE,False)
ov.PutScalarAtElem(UBound(elID)+1,elID,outZ)
ov.Put(ov.ID)

If momentFlag = False Then
momentFlag=True
GoTo MOMENTLOOP:
Else
momentFlag=False
End If
Wend

App.feAppMessage(FCM_ERROR,"Macro is done")
End Sub
 
Hello/Bonjour Francan,

I recognize this piece of code Jacques :)
However I don't use feCoordTransform in it, rather feVectorTransform (similar)

A bit simpler:
App.feCoordTransform(0,center(),userCsys.ID,newCenter())

parameters must have the following types:
1 = Long
2 = double() (size 3)
3 = long
4 = variant

This is a particularity in FEMAP: variables given for output must be variants, eventhough it says in the API they should be double (REAL8). I'm not sure where this comes from, I'm guessing VB6 expects non typed variables, and returns variables with types as indicated in the help.

En gros si dans l'API un paramètre est listé dans "Output" et qu'il a une dimension supérieure à 1 => donner un variant
Je suppose que c'est ce qui plante dans votre code.

Adrien
 
Bonjour à tous,

Merci de votre aide sur le sujet. Je replanche sur le sujet dès que possible et reviens aux nouvelles.
Ce qui est sûr c'est que Adrien a raison, c'est un problème de déclaration des variables qui causait une erreur. Le vecteur résultat doit être un variant sans parenthèses.

Thanks for your help. I will work on this subject soon and come back to give news.
Adrien is right, problem is directly link to declarations. Result vector must be a variant without parentheses


A bientôt,
François
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor