Assembly3 preview

Hello Realthunder,

first thank You for your job, needed as “water in the desert”…

just finished reading these 36 pages, nice reading!

I start playing with it , I got partial success, may be following the tips reported along the thread will help me improving the result.let’s see.
I wanted to export the assembly as a step, but it doesn’t generate any file. I tried making all links and exporting the obj outside assembly, it works but the objects have original placements. any idea?

I’ll work on STEP import/export very soon. But you can already do this now. For any top assembly you want to export, select the assembly, and change its property ‘BuildShape’ to ‘Compound’, then go to Part workbench, menu ‘Part->Export CAD’, and export as STEP file.

++
That would be very helpful to be able to measure e.g. between two circle centers or edge and circle.

I checked out your manipulator workbench. Very nicely done. You seem to already have very rich measurement tools implemented. Are there anything you want in particular, which can’t be done in Python? I think it would be better to have a dedicated workbench for measuring purpose. Part measurement is only for quick one time measuring, as it is not selectable, nor persistent. In fact, there is a Measure workbench in FC source repository, but only contain a python Measurement object. However, it is not a document object, and no Gui view provider either.

I made Manipulator WB because of the missing of some measurements in main branch… I just like the idea to have the measure of a circle in main branch… many users seem not to add external WBs…

BTW I need to adjust Caliper to be fully compatible with A3 :slight_smile:
(I have issues on calculation of placement and I have an issue when adding the annotation plane in measuring)

<asm3.gui> 6.174 - gui.py(53): 
Traceback (most recent call last):
  File "C:\FreeCAD-asm3\Ext\freecad\asm3\FCADLogger.py", line 83, in _catch
    return func(*args,**kargs)
  File "C:\FreeCAD-asm3\Ext\freecad\asm3\gui.py", line 24, in _setElementVisible
    sobj = obj.getSubObject(subname,1)
AttributeError: 'NoneType' object has no attribute 'getSubObject'

Fotr me measuring is a quick tool but i would like so see implemented in FC usebkle in all workbenches. switching between workbenches for one or two measures is time consuming and in the long term annoying…

Right, I may add that in the future.

BTW I need to adjust Caliper to be fully compatible with A3 > :slight_smile:
(I have issues on calculation of placement and I have an issue when adding the annotation plane in measuring)

<asm3.gui> 6.174 - gui.py(53):
Traceback (most recent call last):
File “C:\FreeCAD-asm3\Ext\freecad\asm3\FCADLogger.py”, line 83, in _catch
return func(*args,**kargs)
File “C:\FreeCAD-asm3\Ext\freecad\asm3\gui.py”, line 24, in _setElementVisible
sobj = obj.getSubObject(subname,1)
AttributeError: ‘NoneType’ object has no attribute ‘getSubObject’

>

This is just a warning. I'll fix the code to get rid of it. But it shouldn't affect your operation. Can you elaborate the problem you are having?

I think I need to fix my placement calculation with A3 before being able to see the real reason of my issue… I will update later
Thx :smiley:

Well, you can create a global toolbar (Tools->Customize) to add whatever commands you use the most.
Screenshot from 2018-05-03 16-51-35.png

i know but it different

Hi @realthunder
I’m doing some python code with A3 new features… I have found some small issues:

  1. after starting FC, if I open a ‘.py’ file, the ‘execute macro’ button is not enabled and I get the following error:

Traceback (most recent call last):
File “”, line 1, in
<type ‘exceptions.TypeError’>: Either string or App.Document expected

this is get enabled if I make a new document and then I close it
2) the ‘Visibility’ property for an element inside an Assembly Parts container is always ‘False’
I noticed that this can be changed with ‘Gui.Selection.setVisible()’ but I don’t know how to get the value through a python command
3) it seems the A3 build for win is missing ssl libs

import ssl
Traceback (most recent call last):
File “”, line 1, in
File “C:\FreeCAD-asm3\bin\lib\ssl.py”, line 60, in
import _ssl # if we can’t import it, let the error propagate
ImportError: DLL load failed: The specified module could not be found.

  1. ‘Addons manager’ doesn’t work (this is related to point 3)

Traceback (most recent call last):
File “C:\FreeCAD-asm3\Mod\AddonManager\AddonManager.py”, line 415, in run
u = urllib2.urlopen("> https://github.com/FreeCAD/FreeCAD-addons> ")
File “C:\FreeCAD-asm3\bin\lib\urllib2.py”, line 127, in urlopen
return _opener.open(url, data, timeout)

  1. are Boolean operation available for Links? Is that an useful option or it is not suggested to be enabled?

my release info:
FreeCAD-asm3-20180423-c59a9b24-61466dc-Win64
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.13844 (Git)
Build type: Release
Branch: (HEAD detached at FETCH_HEAD)
Hash: 53a08259946dfa0f02bdd02a7746667902e42728
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
Locale: English/UnitedStates (en_US)

Thx a lot for this amazing new Assembly

Maurice



Copy libeay32.dll and ssleay32.dll from 0.16.6712 will fix these 2. I need to update the libpack used by AppVeyor.

I copied those two to ‘bin’ folder and points 3) and 4) are now fine.
Thx

Noted, and thanks for reporting. I will fix it soon.


  1. the ‘Visibility’ property for an element inside an Assembly Parts container is always ‘False’
    I noticed that this can be changed with ‘Gui.Selection.setVisible()’ but I don’t know how to get the value through a python command

This is by design. ‘Visiblity’ is used by the object to control its own visibility in the global coordinate space. And in the case of App::Part container, the object no longer exists in the global space, so it controls its local coordinate visibility. I don’t like that behavior. I want an object to be able to appear in the global and possibility multiple local coordinate system at the same time with independent visibility control. My ‘Link’ has a group mode that support this with the isElementVisible/setElementVisible() methods. These are core APIs exists in every document object. For those container that supports child visibility control, they will return 1 as visible and 0 as invisible when calling isElementVisible(childName). Those don’t will return -1 instead. The ‘Visiblity’ property is still used to control object’s visibility in global coordinate system. However, since the Element object is not meant to be shown outside of an assembly container, I made its ‘Visibility’ property as read only in Python.

BTW, every property of every object now has dynamic access control using get/setPropertyStatus() function. Very much like the file permission in operating system, the user can choose to override the setting if he knows what he is doing. To remove read only of a property, you can call obj.setPropertyStatus(propName, ‘-Immutable’). To set readonly, call obj.setPropertyStatus(propName,‘Immutable’). Call obj.getPropertyStatus(propName) to get the current access control. Call obj.getPropertyStatus(), i.e. without property name, to obtain all supported access control status name. Note the ‘ReadOnly’ status controls the property editor read-only-ness, while the ‘Immutable’ controls the Python access, for backward compatibility reason. The property access control status is persistent. Also, C++ code is able to set permanent access control which cannot be overridden.


  1. are Boolean operation available for Links? Is that an useful option or it is not suggested to be enabled?

I am not sure I understand this question. Do you want to use Link as a tool or base in some Part boolean operation? You can already do this with the version you have. There is even a command to replace an existing tool or base of a Part feature with a Link. Simply switch to Part workbench, right click a object you want to replace in the tree view, and select ‘Link actions → Replace with a link’. To revert, use ‘Link actions → Unlink’.


Thx a lot for this amazing new Assembly

And I want to thank you for testing. You’re probably the first one to try development using my branch.


PS. I have just added Part shape copy with color you asked for, although you’ll need to wait for the next release to be able to test it. After assigning the Part::Feature with a shape from another object, call the Part::Feature’s view object’s new method mapShapeColors(doc). The ‘doc’ is the owner document of the object the shape comes from. In case the object comes from the same document, you can omit that. If not, then this argument enables retrieving color from the external object. I enhanced Part simple copy with this new method. Also added Transformed copy (copy that respects local coordinates) and Element copy (Face, Edge, Vertex copy). The copy command supports any objects with or without shape (such as Assembly container, and App::Part), either in the same or from external document.

Thx

I will try to use these info in my code… I still have to fully understand the new context environment. Thx

For example, in the attached screencast, I have two Links of objects and I would like to do a ‘Boolean Cut’ of those Links, but the ‘Cut’ button is greyed on part WB.
links-Cuts.gif
I’m testing your Links with my StepUp WB and every is working just fine… Moreover Links are fantastic for a component re-used many times i.e. resistors with the same case or switch-buttons etc..
This is much faster for boards with many equal pieces used many times and this could be very useful for mechanical assemblies where i.e. bolts are re-used many many times…
What I’m developing is a macro that is simplifying an Assembly or a Part tree with Links to a correspondent Part simplified tree with links converted to its shape, but conserving the placements as in the Assembly structure.
This is also useful to export even a complex Assembly to STEP format. I know you are working on that too, but this is an other option trough a python macro.
ATM I miss the Visibility info :wink:

Thx also for this :smiley:
Maurice

My Link poses minimum restriction regarding which object can be added to which container. This makes things easy for the end-users. But unfortunately, the developer has to pay the price, as it is now much more complicated to navigate an object hierarchy. Here are some methods in Assembly3 to help with the navigation

from freecad.asm3 import assembly as asm

# to check if an object is an Assembly container,

asm.isTypeOf(obj, asm.Assembly)

# to check if an object is an Assembly container or is a link to an Assembly container

asm.isTypeOf(obj,asm.Assembly,True)

# once you know it is an assembly, extract its proxy object like this.
# getLinkedObject(True) will return the final linked object regardless how many levels of
# indirection in-between. For non-Link-type object, it returns itself. So it is always safe to call.

assembly = obj.getLinkedObject(True).Proxy

# from there you can easily get its children.

constraintGroup = assembly.getConstraintGroup()
elementGroup = assembly.getElementGroup()
partGroup = assembly.getPartGroup()

# The above function returns the object. To access Assembly3 API you'll need to use its Proxy.
# Each group object has a python method to obtain its parent assembly, so

assembly == partGroup.Proxy.getAssembly()

# To obtain/change the children visibility. This applies to all three groups above

for child in partGroup.Group:
	partGroup.isElementVisible(child.Name)
	partGroup.setElementVisible(child.Name,True)
	
# All assembly document objects are defined in assembly.py file.
# ElementGroup is of type AsmElementGroup, and its children is of type AsmElement
# Given an element you can obtain the parent element group and parent assembly easily.

for child in elementGroup.Group:
	child.Proxy.parent == elementGroup.Proxy
	child.Proxy.getAssembly() == assembly
	
# ConstraintGroup is of type AsmConstraintGroup, and its children is of type AsmConstraint,
# and its children is of type AsmElementLink. Every children can obtain the direct parent, and
# parent assembly container the same way as above.



Right, I thought I have fixed that. But apparently not. For now, you can work around like this.




Exactly, I have that use case in mind long before I started asm3. In fact, even before I started working on Link.

Hi,
just a thought too boolean operations inside a assembly..:

In my mind assembly schould by able to put and fix ready parts together, not creating new parts. A aperation, like Maurice shows a post above, creates a new part. - In my mind not the task of assembly.

This is useful not for making a new part, but for checking collision among an Assembly and external Objects/Parts… or even inside an Assembly, to check if aligned objects are colliding…
An other case in which a union of the Assembly is useful is if you want to export the assembly for i.e. 3D printing or as a STEP unioned model…
Then, in my user case, this is a task of Assembly

__When will Assembly 3 be part of FreeCAD Daily builds? A lot more will test it out when this happens.



THX!!!

I played with a quite complex assembly, by activating autorelax, replacing some “plane alignment” with “point on plane” did the wanted result! and more adjustable than asm2!

One feature request, do You think we can have angle alignment splitted in vertical angle and horizontal angle?