FreeCAD as pre-post processor for MBDyn

About the development of the FEM module/workbench.

Moderator: bernd

josegegas
Posts: 241
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post procesor for MBDyn

Post by josegegas »

Yes, you are right, I think I need a bit more planning and less coding haha. Great advice, thanks!
User avatar
HarryvL
Veteran
Posts: 1285
Joined: Sat Jan 06, 2018 7:38 pm
Location: Netherlands

Re: FreeCAD as pre-post procesor for MBDyn

Post by HarryvL »

josegegas wrote: Wed Nov 20, 2019 5:04 am Hi. Every time I make a change to the code, to test if it works as intended, I have to close FreeCAD and open it again, so that it "loads" the module with the changes... This is making me loose too much time. Is there a way to avoid this? Like forcing FreeCAD to load the module without closing it and opening again? I've tested to go from one workbench to another, but it seems FreeCAD loads all only once. How do you guys work?
Try reload(). See here: https://forum.freecadweb.org/viewtopic. ... lit=reload
josegegas
Posts: 241
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post procesor for MBDyn

Post by josegegas »

Another quick question. Is there any method that gets executed when the user clicks (single click) on a given object in the tree view? What I want to achieve: When the user clicks on an object, some other objects in the 3D scene get highlighted. Is this possible?
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: FreeCAD as pre-post procesor for MBDyn

Post by vocx »

josegegas wrote: Wed Nov 20, 2019 12:08 pm Another quick question. Is there any method that gets executed when the user clicks (single click) on a given object in the tree view? What I want to achieve: When the user clicks on an object, some other objects in the 3D scene get highlighted. Is this possible?
I think what you want sounds like is possible but only in C++. That's basically what realthunder did in 0.19. Now when you hover over an object in the tree view, the corresponding element is highlighted in the 3D view.

Maybe there is an interface to override this behavior, but I wouldn't know for certain, you'd have to ask realthunder.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: FreeCAD as pre-post procesor for MBDyn

Post by microelly2 »

josegegas wrote: Wed Nov 20, 2019 12:08 pm Another quick question. Is there any method that gets executed when the user clicks (single click) on a given object in the tree view?
selection observer can handle selections

Code: Select all


class SelObserver:

    def addSelection(self,doc,obj,sub,pnt): 
        print ("Selection added",obj)


s =SelObserver()
FreeCADGui.Selection.addObserver(s)                       # install the function mode resident
#FreeCADGui.Selection.removeObserver(s)                   # Uninstall the resident function 

User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: FreeCAD as pre-post procesor for MBDyn

Post by microelly2 »

here an example how I use reload for fast development. I use some naming convention and reloads the implementation file for each call

Code: Select all

class FreeCadNodeBase(NodeBase):
    '''common methods for FreeCAD integration'''
    
    
    def __init__(self, name="FreeCADNode",**kvargs):
        
        super(FreeCadNodeBase, self).__init__(name)
        self._debug = False
        self._preview=False
    
    @timer
    def compute(self, *args, **kwargs):
        if self._debug:
            say("debug on for ",self)
        import nodeeditor.dev
        reload (nodeeditor.dev)
        a=eval("nodeeditor.dev.run_{}(self)".format(self.__class__.__name__))
        if self._debug: say("Done:",self)
        if self._preview:
            say("create preview")
            self.preview()
The class definition - here I only define the interface (parameters)

Code: Select all

class FreeCAD_Blinker(FreeCadNodeBase):
    '''
    blinker sender
    '''

    def __init__(self, name="baked",**kvargs):

        super(self.__class__, self).__init__(name)
        self.inExec = self.createInputPin(DEFAULT_IN_EXEC_NAME, 'ExecPin', None, self.compute)
        self.outExec = self.createOutputPin(DEFAULT_OUT_EXEC_NAME, 'ExecPin')
        self.signal=self.createInputPin('signalName', 'StringPin', 'blink')
        self.data=self.createInputPin('signalMessage', 'StringPin')
        self.d3=self.createInputPin('signalObject', 'FCobjPin')
        self.d3=self.createInputPin('sleep', 'FloatPin')
and the compute fucntion in noteeditor/dev.py

Code: Select all

def run_FreeCAD_Blinker(self):
 ....
louisgag
Posts: 75
Joined: Fri Jan 17, 2020 9:59 am

Re: FreeCAD as pre-post procesor for MBDyn

Post by louisgag »

Hi José and everyone,

I read this whole thread and found some quite interesting discussions.
I've been involved with the development of MBDyn and was responsible for the team's participation in GSoC.
We do have another MBDyn pre/postprocessor addon for FreeCAD, but it needs improvement.
Because of that, it would be nice if you could release the code, even if it is not production-ready, so that we and others can build on it. (We are planning on participating in GSoC again this year)

I agree with your mention that MBDyn would be suitable as an alternative to animate the currently available assembly options.
To do so, what you want is to build a fully constrained MBDyn model using only static nodes.

Send me an email if you want to discuss this further and I'll get you in touch with the main developer of pre- and post-processing solutions for MBDyn.

Kind regards,

-Louis
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: FreeCAD as pre-post procesor for MBDyn

Post by Kunda1 »

josegegas wrote::point_up_2:
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
louisgag
Posts: 75
Joined: Fri Jan 17, 2020 9:59 am

Re: FreeCAD as pre-post procesor for MBDyn

Post by louisgag »

You're suggesting I write a private message? I already tried two weeks ago, but it just stayed forever in my outbox... maybe because I'm new to the forum?
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: FreeCAD as pre-post procesor for MBDyn

Post by microelly2 »

louisgag wrote: Fri Feb 07, 2020 9:07 am You're suggesting I write a private message? I already tried two weeks ago, but it just stayed forever in my outbox... maybe because I'm new to the forum?
No, the receiver died not read the mail yet.
Post Reply