Assembly 4 workbench

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
WayofWood
Posts: 62
Joined: Mon Nov 26, 2018 4:59 pm

Re: Assembly 4 workbench

Post by WayofWood »

Hi,

Thanks a lot for sharing the development version. The measure tool is really nice.

Regarding the BOM/Partlist the code would obviously need a bit more love (like a dialogue to choose the file to export to, etc.). Happy to try my hands on that.

I was working a little bit with Assembly 4 and the partlist idea. I have to say that from a usability point of view using a spreadsheet (like in A2+) seems easier to me than editing variables (even if the variables would get meaningful default values). The same applies BTW to other variables as well. In my workflow I usually tend to store the variables in a central spreadsheet and then link to these in the Variables-Section within Assembly4.

So my question to all: How would the ideal workflow for a BOM look like?
  • Like in A2+: Each part has a spreadsheet with part information that is then consolidated in one sheet
  • Variable-based: All the information are stored as variables and then exported as a CSV? (similar to the current poc)
  • Central database: One could also store all the necessary info (like supplier, price, etc.) in a central spreadsheet and only have an ID as a variable
My personal preference would be to store the info in a spreadsheet and then save a csv file -- but I would be curious to hear from others what they think.
drmacro
Veteran
Posts: 8978
Joined: Sun Mar 02, 2014 4:35 pm

Re: Assembly 4 workbench

Post by drmacro »

WayofWood wrote: Mon Jun 15, 2020 12:10 pm Hi,

Thanks a lot for sharing the development version. The measure tool is really nice.

Regarding the BOM/Partlist the code would obviously need a bit more love (like a dialogue to choose the file to export to, etc.). Happy to try my hands on that.

I was working a little bit with Assembly 4 and the partlist idea. I have to say that from a usability point of view using a spreadsheet (like in A2+) seems easier to me than editing variables (even if the variables would get meaningful default values). The same applies BTW to other variables as well. In my workflow I usually tend to store the variables in a central spreadsheet and then link to these in the Variables-Section within Assembly4.

So my question to all: How would the ideal workflow for a BOM look like?
  • Like in A2+: Each part has a spreadsheet with part information that is then consolidated in one sheet
  • Variable-based: All the information are stored as variables and then exported as a CSV? (similar to the current poc)
  • Central database: One could also store all the necessary info (like supplier, price, etc.) in a central spreadsheet and only have an ID as a variable
My personal preference would be to store the info in a spreadsheet and then save a csv file -- but I would be curious to hear from others what they think.
I installed just now and it does appear to be ok. (I'm using the daily build.)

How the BOM should look and work is an interesting question.

The first assembly I opened and used the BOM tool on was an assembly of various lengths of angle, some fasteners, and a motor.

In the "real world" there are different types of BOM's: Manufacturing, Assembly, Purchasing, etc.

For a manufacturing BOM, that would go to the machine shop for example, the BOM would probably refer to a list of detailed drawings. Each drawing providing the details of the part to be made. So the detailed drawing of, say, my "inner_angle_right", would detail the material and cut lengths.

The purchasing BOM may only specify the part number of the motor to procure.

The fastener detail would probably refer to a part number and the part number would provide the material, finish, etc. for the purchasing department. Not sure the size of an M12-Nut (18.0 x 10.8 x 20.7) would be relevant.

But, this is a great start (I'd been wondering about BOM with A4 since I started using it...).

The BOM produced would let me actually print it as is and go to my shop and cut the angles needed to make the assembly! :)

The measure tool is great and allows reference measurements in the assembly.

I noticed they did not update if the part is moved. (I don't think the Manipulator WB created dims do either??) But, it would be a nice feature. If I need to manually change dimensions every time I update the assembly, it could get tedious.
Zolko wrote: Sun Jun 14, 2020 10:00 pm
Let me know if there are any particulars you'd like tested.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
OficineRobotica
Posts: 433
Joined: Thu Feb 21, 2019 8:17 am
Contact:

Re: Assembly 4 workbench

Post by OficineRobotica »

I'm late to the party. Downloading and testing tonight. I don't know why, half of the times, I don't get notifications if someone ping's me.
Check out my Youtube channel at: https://www.youtube.com/@OficineRobotica
User avatar
WayofWood
Posts: 62
Joined: Mon Nov 26, 2018 4:59 pm

Re: Assembly 4 workbench

Post by WayofWood »

I extended the code a little bit:

Code: Select all

import FreeCAD,Draft
import csv
import string

from PySide import QtCore
from PySide import QtGui

forbbox = ('PartDesign::Body', 'Part::Feature', 'Part::FeaturePython')
debug = 0

def dprint(str):
	if (debug ==1):
		print (str)

def Partlist(object,level=0,tab=None,parent=None):
    indent = '  '*level
    if tab == None:
        tab = {}
    if object.TypeId=='App::Link':
        dprint(indent+object.Label+' -> '+object.LinkedObject.Document.Name+'#'+object.LinkedObject.Label+' => '+object.LinkedObject.FullName)
        Partlist(object.LinkedObject,level+1,tab, object)
    else:
        dprint(indent+object.Label+' ('+object.TypeId+')')
        if hasattr(object, 'Shape') and object.TypeId in forbbox:
            if object.FullName in tab:
                tab[object.FullName]["count"] = tab[object.FullName]["count"] + 1
            else:
                tab[object.FullName] = {}
                tab[object.FullName]["var"] = {} 
                tab[object.FullName]["count"] = 1
                tab[object.FullName]["partlist"] = {}

            tab[object.FullName]['label'] = object.Label
            tab[object.FullName]['fullname'] = object.FullName
            tab[object.FullName]['Id'] = object.Label
            bb=object.Shape.BoundBox
            tab[object.FullName]['xlen'] = bb.XLength
            tab[object.FullName]['ylen'] = bb.YLength
            tab[object.FullName]['zlen'] = bb.ZLength
            tab[object.FullName]['volume'] = str(object.Shape.Volume)

            try:
                table = parent.getObject('_PARTINFO_')
                dprint(indent+'    '+"Found Partinfo table\n")

                for i in range(1,100):
                    key = table.get("A"+str(i))
                    val = table.get("B"+str(i))

                    dprint(indent+'    '+key+" = "+val)
                    tab[object.FullName]["partlist"][str(key)] = str(val)
            except:
                dprint(indent+'    '+"No partlist found\n")

            if hasattr(object, 'AttachedTo'):
                tab[object.FullName]['attachedto'] = object.AttachedTo

            dprint (indent+" => BBox: "+str(object.Shape.BoundBox))		
            dprint (indent+" => Volume: "+str(object.Shape.Volume))		
        if object.TypeId=='App::Part':
            # look for Variables
            if object.Document.getObject( 'Variables' ):
                dprint(indent+'  Variables:')
                vars = object.Document.getObject( 'Variables' )
                for prop in vars.PropertiesList:
                    if vars.getGroupOfProperty(prop)=='Variables' :
                        propValue = vars.getPropertyByName(prop)
                        dprint(indent+'    '+prop+' = '+str(propValue))
                        if not object.FullName in tab:
                            tab[object.FullName] = {}
                            tab[object.FullName]['fullname'] = object.FullName
                            tab[object.FullName]["var"] = {}
                            tab[object.FullName]["partlist"] = {}
                        tab[object.FullName]["var"][prop] = str(propValue) 
            # look for sub-objects
            for objname in object.getSubObjects():
                subobj = object.Document.getObject( objname[0:-1] )
                Partlist(subobj,level+1, tab, object)
    return tab


def dictoarr(tab): 
	keys = {}
	for obj in tab.keys():
		if isinstance(tab[obj], dict):
			for key in tab[obj].keys():
				if isinstance(tab[obj][key], dict):
					for inner_key in tab[obj][key].keys():
						keys[key+"."+inner_key] = {};
						keys[key+"."+inner_key][0] = key;
						keys[key+"."+inner_key][1] = inner_key;
				else:
						keys[key] = 1;
	headings = sorted(keys.keys())

	arr = [ headings ]
	for obj in sorted(tab.keys()):
		line = []
		for head in headings:
			value = ''
			lookup = keys[head]
			if isinstance(lookup, dict):
				if lookup[0] in tab[obj] and lookup[1] in tab[obj][lookup[0]]: 	
					value = tab[obj][lookup[0]][lookup[1]]
			else:
				if head in tab[obj]:
					value = tab[obj][head]
			line.append(value)
		arr.append(line)	
	return arr


a = Partlist(FreeCAD.ActiveDocument.getObject("Model"), 0)
dprint("\n\n")
dprint(a)
t = dictoarr(a)
dprint("\n\n")
dprint(t)

fileName = "/tmp/test.csv"

if fileName:
	with open(fileName, 'w') as csvfile:
	    writer = csv.writer(csvfile, delimiter="\t")
	    writer.writerows(t)
You can now create a PartInfo table with A2+ and if you move it from the top-level of the file into the Model it will be integrated into the export table.

Apologies for the bad code. Unfortunately I never learned how to write proper code - just enough to somehow get things done. :oops:
User avatar
OficineRobotica
Posts: 433
Joined: Thu Feb 21, 2019 8:17 am
Contact:

Re: Assembly 4 workbench

Post by OficineRobotica »

I just tried the new dev branch and the measure tool is a extremely helpful addition.
Some considerations:

- wouldn't it be helpful to change the description in the initGui.py to something like ASM4_dev so that FC sees it as a different workbench and the trunk and dev versions could live together? Whoever uses the dev version doesn't mind having 2 voices in the drop down menu. I don't know the technical difficulty in doing that but it would be nice to not have to swap folders in the mod directory.

-the tool tip should just say "caliper" or "measure tool"

-as we all have some messed up trees in our projects it would be nice to automatically create a folder for the measures similar to the one created for the "parts" . As a user experience enhancement, the "measure line" should be a sub element of the "measure label" in the tree. Or hide "measure line" voice completely if it doesn't serve a function in selecting it at a later moment. Extending on that, I always wished to group "LCS's" of bodies in a folder for some tree view ordering but unfortunately, placing an LCS inside a folder will render it invisible to A4 to manipulate later. Can this be addressed in some way?

-double clicking the "distanceLine" in the tree bring's up the transform dialog but no visual 3d manipulator in the 3d view. Is this intended?

-double clicking the "distanceLbl" should bring up the "measure tool" dialog with the "results" displayed for that label

-this is more of a trunk version small usability issue. The Icons for create LCS, datum plane, datum axis etc in part should be more "colorful" when active. There is little to no contrast between states especially when using a dark style sheet.

Thank you devs for your work. Cheers.
Check out my Youtube channel at: https://www.youtube.com/@OficineRobotica
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly 4 workbench

Post by Zolko »

OficineRobotica wrote: Tue Jun 16, 2020 6:13 am - wouldn't it be helpful to change the description in the initGui.py to something like ASM4_dev so that FC sees it as a different workbench
I understand, but that would defeat the purpose of a development system as it would be different from the real one. What I do is that I link my development directory to the Mod directory, and when I need to test the real system I delete the link and install Asm4 by the AddonsManager.

-as we all have some messed up trees in our projects it would be nice to automatically create a folder for the measures similar to the one created for the "parts"
good idea, will do

Extending on that, I always wished to group "LCS's" of bodies in a folder for some tree view ordering but unfortunately, placing an LCS inside a folder will render it invisible to A4 to manipulate later. Can this be addressed in some way?
I don't know. Someone-else can chime-in ?

-this is more of a trunk version small usability issue. The Icons for create LCS, datum plane, datum axis etc in part should be more "colorful" when active. There is little to no contrast between states especially when using a dark style sheet.
If you can propose something I'd be glad to include it

-double clicking the "distanceLine" in the tree bring's up the transform dialog but no visual 3d manipulator in the 3d view. Is this intended?
-double clicking the "distanceLbl" should bring up the "measure tool" dialog with the "results" displayed for that label
drmacro wrote: Mon Jun 15, 2020 1:32 pm I noticed they did not update if the part is moved.
yes, they're static objects.
try the Assembly4 workbench for FreCAD — tutorials here and here
C_h_o_p_i_n
Posts: 225
Joined: Fri Apr 26, 2019 3:14 pm

Re: Assembly 4 workbench

Post by C_h_o_p_i_n »

Hej Zolko,

I'm thinking about a "simulation" of an Assembly which constist partially of a flexible part.
Do you have any suggestions on this topic - how to - or an example where something similar might have been done?

Regards,
Stefan
User avatar
ppemawm
Veteran
Posts: 1240
Joined: Fri May 17, 2013 3:54 pm
Location: New York NY USA

Re: Assembly 4 workbench

Post by ppemawm »

C_h_o_p_i_n wrote: Wed Jun 17, 2020 11:19 am an example where something similar might have been done?
https://forum.freecadweb.org/viewtopic.php?f=24&t=42671

I do not know if this is similar but if you can describe how the flexible part changes using constraints in a master sketch
you can animate it with Assembly4.
"It is a poor workman who blames his tools..." ;)
MaurinoWeb
Posts: 221
Joined: Thu Jun 22, 2017 1:15 pm

Re: Assembly 4 workbench

Post by MaurinoWeb »

ppemawm wrote: Wed Jun 17, 2020 11:30 am
C_h_o_p_i_n wrote: Wed Jun 17, 2020 11:19 am an example where something similar might have been done?
https://forum.freecadweb.org/viewtopic.php?f=24&t=42671

I do not know if this is similar but if you can describe how the flexible part changes using constraints in a master sketch
you can animate it with Assembly4.
Thanks... all very interesting, I always follow with interest.

I didn't know that the tube bender had already been created with assembly4, I wanted to make one to show in the workshop... excellent! very beautiful. Congratulations!

I also followed the link for the variables on page 35, I missed it ... I want to take a look at that file too.

Always thanks to everyone
C_h_o_p_i_n
Posts: 225
Joined: Fri Apr 26, 2019 3:14 pm

Re: Assembly 4 workbench

Post by C_h_o_p_i_n »

ppemawm wrote: Wed Jun 17, 2020 11:30 am
C_h_o_p_i_n wrote: Wed Jun 17, 2020 11:19 am an example where something similar might have been done?
https://forum.freecadweb.org/viewtopic.php?f=24&t=42671

I do not know if this is similar but if you can describe how the flexible part changes using constraints in a master sketch
you can animate it with Assembly4.
That is, what I was looking for - Thanks ...!
Post Reply