force direction with App.Vector

About the development of the FEM module/workbench.

Moderator: bernd

Post Reply
shahram10715
Posts: 22
Joined: Sat Apr 20, 2019 7:09 am
Contact:

force direction with App.Vector

Post by shahram10715 »

If I try to type the following command:

Code: Select all

App.ActiveDocument.FemConstraintForce.Direction = (App.ActiveDocument.Line002,["Edge1"])
there is no problem, but if I change the above code to the following I get a type error. Is there any chance to add this type to input?

Code: Select all

App.ActiveDocument.FemConstraintForce.Direction = (App.Vector(1,0,0)) 
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: Property 'Direction': type must be 'DocumentObject', 'NoneType' or ('DocumentObject',['String',]) not Base.Vector
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: force direction with App.Vector

Post by bernd »

The error message said it
shahram10715 wrote: Fri Jan 31, 2020 10:14 am TypeError: Property 'Direction': type must be 'DocumentObject', 'NoneType' or ('DocumentObject',['String',]) not Base.Vector
You should provide a document object and a element (in this case an Edge) of this document objects shape. You did it in your first example.

You should not provide a vector. It is what you did in your second example.

bernd
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: force direction with App.Vector

Post by bernd »

shahram10715 wrote: Fri Jan 31, 2020 10:14 am ... Is there any chance to add this type to input? ...
Not an simple one.


in FEM examples either an Edge of the object which was meshed is taken https://github.com/FreeCAD/FreeCAD/blob ... is.py#L138 or a line is created just for the load direction https://github.com/FreeCAD/FreeCAD/blob ... y#L96-L102 and https://github.com/FreeCAD/FreeCAD/blob ... ll.py#L164
shahram10715
Posts: 22
Joined: Sat Apr 20, 2019 7:09 am
Contact:

Re: force direction with App.Vector

Post by shahram10715 »

Thanks a lot, so if I don't have an edge in that direction I must first draw a line in that direction, and then assign it.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: force direction with App.Vector

Post by bernd »

shahram10715 wrote: Fri Jan 31, 2020 12:55 pm ... if I don't have an edge in that direction I must first draw a line in that direction, and then assign it.
exactly
hex41434
Posts: 12
Joined: Mon Mar 01, 2021 11:03 am

Re: force direction with App.Vector

Post by hex41434 »

Hi,

I have a similar problem, I would like to apply force on specific position on my fem mesh ... should I also add a Face and pass its name as string to: "App.ActiveDocument.ConstraintForce.References"? seems a bit weird...
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: force direction with App.Vector

Post by Jee-Bee »

if had read this you had seen the a sketch an a line was enough
hex41434
Posts: 12
Joined: Mon Mar 01, 2021 11:03 am

Re: force direction with App.Vector

Post by hex41434 »

Thank you Jee-Bee,

I still think that my question is a bit different

based on this link:
https://github.com/FreeCAD/FreeCAD/blob ... #L157-L165

I tried to create a vector and add it as force constraint.
force_constraint.References = [(force_point, "Vertex1")]
but finally I got this error:

/Fem/femmesh/meshtools.py", line 775, in get_force_obj_vertex_nodeload_table
(elem_info_string, {node[0]: node_load / node_count})
list index out of range

could you please help me to solve this, using "face" instead of "edge" ?

Thanks in advance
hex41434
Posts: 12
Joined: Mon Mar 01, 2021 11:03 am

Re: force direction with App.Vector

Post by hex41434 »

hex41434 wrote: Mon Mar 01, 2021 2:26 pm Thank you Jee-Bee,

I still think that my question is a bit different

based on this link:
https://github.com/FreeCAD/FreeCAD/blob ... #L157-L165

I tried to create a vector and add it as force constraint.
force_constraint.References = [(force_point, "Vertex1")]
but finally I got this error:

/Fem/femmesh/meshtools.py", line 775, in get_force_obj_vertex_nodeload_table
(elem_info_string, {node[0]: node_load / node_count})
list index out of range

could you please help me to solve this, using "face" instead of "edge" ?

Thanks in advance
I solved it... I choose wrong Vertex position, when I updated the vertex position it worked! Thanks
Post Reply