assembly without solver

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: assembly without solver

Post by Zolko »

Nice. I've managed to port some of the macros over to the WB, I'll upload them in an hour. Not all though yet
try the Assembly4 workbench for FreCAD — tutorials here and here
emills2
Posts: 875
Joined: Tue Apr 28, 2015 11:23 pm

Re: assembly without solver

Post by emills2 »

activeDoc is defined at line 42, part of
def Activated(self)
so it is local to Activated()

then you call it at line 113, as part of
def getAllParts(self)

getAllParts() is itself called within Activated(), AFTER you declare activeDoc = FreeCAD.ActiveDocument, BUT you changed function level! and you did not specifically pass activeDoc. you passed self.

i changed line 48, and passed a parameter

Code: Select all

		self.getAllParts(activeDoc)
amd i changed the corresponding definition on line 109 to receive the parameter

Code: Select all

	def getAllParts(self,activeDoc):
the error went away from the report view, but still an empty window. did you see the same error from my previous post?
Assembly4_insert_link_bugs_01.PNG
Assembly4_insert_link_bugs_01.PNG (101.41 KiB) Viewed 6228 times
emills2
Posts: 875
Joined: Tue Apr 28, 2015 11:23 pm

Re: assembly without solver

Post by emills2 »

after looking through a little bit more, i figure your style would probably be more like

line 42

Code: Select all

		self.activeDoc = FreeCAD.ActiveDocument
line 109

Code: Select all

	def getAllParts(self):
and line 113

Code: Select all

			if doc != self.activeDoc:
still looking for the actual problem. i haven't played with the custom windows before, so this is interesting, even you have it all sorted out already.
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: assembly without solver

Post by Zolko »

emills2 wrote: Tue Feb 19, 2019 8:18 am after looking through a little bit more, i figure your style would probably be more like
my coding "style" ... that's a good one.

Well, I managed to make the workbench work on my computer. There are still warnings, but so far all works as expected ... by me. That is, as soon as other people will try, it'll break. And then, I'd like to fix it, to bring this workbench / framework to a usable state for the average Joe, and then we can extend it with fancier features. Version 0.2 of this workbench can be found on:

https://github.com/Zolko-123/FreeCAD_aw ... 4_v0.2.zip

To be extracted into ~/.FreeCAD/Mod
try the Assembly4 workbench for FreCAD — tutorials here and here
emills2
Posts: 875
Joined: Tue Apr 28, 2015 11:23 pm

Re: assembly without solver

Post by emills2 »

doesn't seem to want to load the workbench
'module' object has no attribute 'PrintWarning'
Traceback (most recent call last):
File "<string>", line 47, in Initialize
this one is pretty baffling. 'PrintWarning' dosen't seem to exist anywhere in your files :lol:
emills2
Posts: 875
Joined: Tue Apr 28, 2015 11:23 pm

Re: assembly without solver

Post by emills2 »

InitGui.py: i switched the contents of Activated and Initialize (by simply changing the function name in the definition).

the workbench now loads. on my machine at least, you cannot pass on Initialize. you can pass on Activated.

Code: Select all

	def Activated(self):
		#self.appendMenu(["&Edit","DynamicData"],self.list) # appends a submenu to an existing menu
		pass


	"""
    ╔═══════════════════════════════════════════════╗
    ║                      Menu                     ║
    ╚═══════════════════════════════════════════════╝
	"""
    def showMenu(self):
        from PySide import QtGui
        window = QtGui.QApplication.activeWindow()
        #freecad hides wb toolbars on leaving wb, we unhide ours here to keep it around
        #if the user has it set in parameters to do so
        pg = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Assembly4")
        keep = pg.GetBool('KeepToolbar',True)
        if not keep:
            return
        tb = window.findChildren(QtGui.QToolBar) 
        for bar in tb:
            if "Assembly 4" in bar.objectName():
                bar.setVisible(True)



	"""
    ╔═══════════════════════════════════════════════╗
    ║          Standard necessary functions         ║
    ╚═══════════════════════════════════════════════╝
	"""
    def Initialize(self):
        "This function is executed when the workbench is activated"
        import newModelCmd     # creates a new App::Part container called 'Model'
        import newSketchCmd    # creates a new Sketch in 'Model'
        import newLCSCmd       # creates a new LCS in 'Model'
        import newBodyCmd      # creates a new Body in 'Model
        import insertLinkCmd   # inserts an App::Link to a 'Model' in another file
        import placeLinkCmd    # places a linked part by snapping LCS (in the Part and in the Assembly)
        import placeLCSCmd     # places an LCS relative to an external file (creates a local attached copy)
        #self.list = ["newModelCmd", "placeLinkCmd", "DynamicDataAddProperty", "DynamicDataRemoveProperty", "DynamicDataImportNamedConstraints","DynamicDataCopyProperty","DynamicDataSettings"] # A list of command names created in the line above
        self.listCmd =           [ "newModelCmd", "newSketchCmd", "newLCSCmd", "newBodyCmd", "insertLinkCmd", "placeLinkCmd", "placeLCSCmd" ] # A list of command names created in the line above
        self.itemsMenu =         [ "newModelCmd", "newSketchCmd", "newLCSCmd", "newBodyCmd", "insertLinkCmd", "placeLinkCmd", "placeLCSCmd" ] # A list of command names created in the line above
        self.itemsToolbar =      [ "newModelCmd", "newSketchCmd", "newLCSCmd", "newBodyCmd", "insertLinkCmd", "placeLinkCmd", "placeLCSCmd" ] # A list of command names created in the line above
        self.itemsContextMenu =  [ "placeLinkCmd", "placeLCSCmd" ] # A list of command names created in the line above
        self.appendToolbar("Assembly 4",self.itemsToolbar) # leave settings off toolbar
        self.appendMenu("&Assembly",self.itemsMenu) # creates a new menu
        return

ok! now i'm going to try to do something.
emills2
Posts: 875
Joined: Tue Apr 28, 2015 11:23 pm

Re: assembly without solver

Post by emills2 »

ok, now i'm back to where i was previously. good.

i built the same 2 parts, 3 instances assembly as before, edited the LCS sketch, got the live update.

i deleted the linked parts, the corresponding constraints are still in the folder. is there a some kind of "OnDelete()" available to deal with this?

i readded the parts, without carefully creating unique labels, and it renamed the second instance by itself, and the constraint followed! excellent. i placed the links, and each tracks individually. good stuff!

gotta wait til next weekend to try much more.

i'm not sure what 'attach an LCS to an external part' is all about.
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: assembly without solver

Post by Zolko »

emills2 wrote: Wed Feb 20, 2019 4:59 am 'module' object has no attribute 'PrintWarning'
Traceback (most recent call last):
File "<string>", line 47, in Initialize
yeah, I don't know what that is. So I went back to v0.1 and forward-ported the commands from v0.2. That makes the v0.3. This one loads and works on my computer ... but so did v0.2 before uploading. I created an Assembly 4 repository, but I don't know how to use it

emills2 wrote: Wed Feb 20, 2019 5:50 am i deleted the linked parts, the corresponding constraints are still in the folder. is there a some kind of "OnDelete()" available to deal with this?
hum, I dunno now, must check

i readded the parts, without carefully creating unique labels, and it renamed the second instance by itself, and the constraint followed! excellent. i placed the links, and each tracks individually. good stuff!
yes, that was important, and I got it from your scripts

i'm not sure what 'attach an LCS to an external part' is all about.
nested assemblies. Assembly in an assembly inside another assembly. It's the next workshop
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: assembly without solver

Post by Zolko »

In this image, there are ~300 parts, in sub-assemblies and sub-sub-assemblies, of ~10 different types. This assembly structure allows to make really really large assemblies now. A 4x2 brick is 432Kb, the entire assembly just 30Kb ! But the fact that each included part has an open window begins to be problematic.

Lego_HouseGarden.png
Lego_HouseGarden.png (514.72 KiB) Viewed 6069 times
try the Assembly4 workbench for FreCAD — tutorials here and here
emills2
Posts: 875
Joined: Tue Apr 28, 2015 11:23 pm

Re: assembly without solver

Post by emills2 »

Zolko wrote: Wed Feb 20, 2019 8:56 am but I don't know how to use it
i never do anything more complicated than shown here actually usually much less complicated:
http://rogerdudler.github.io/git-guide/

creating a local git folder and cloning a github repo i only did once or twice. wasn't hard, but can't remember clearly. i don't use the fancy github GUI tool, but they also give you a "Git Shell". which is awesome because it give me a good unix shell on windows

in practice, day to day looks like this

cd ~
cd ./AppData/Roaming/FreeCAD/Mod/Silk (get to my git folder)
git status (shows me how many files i changed, in red)
git add --all (i basically always add all my changes)
git status (shows me how many files i added to the 'queue', now in green)
git commit -m 'mandatory commit message' (i actually have to type in something here)
git status (shows me all changes are taken care of)
git push origin master ('push' all commits to github)

if i actually did something through the website, like accept soemone's contribution, then i
git pull

that's it.

in Git Shell on windows, i just pull all the commands from history, and only type the message.
Post Reply