Assembly3 preview

Discussion about the development of the Assembly workbench.
User avatar
easyw-fc
Posts: 2689
Joined: Thu Jul 09, 2015 9:34 am

Re: Assembly3 preview

Postby easyw-fc » Fri May 04, 2018 9:38 am

realthunder wrote:
Thu May 03, 2018 6:47 am
...A3...
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 "<string>", line 1, in <module>
<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 "<input>", line 1, in <module>
File "C:\FreeCAD-asm3\bin\lib\ssl.py", line 60, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified module could not be found.
4) '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)
5) 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
User avatar
sgrogan
Posts: 5453
Joined: Wed Oct 22, 2014 5:02 pm

Re: Assembly3 preview

Postby sgrogan » Fri May 04, 2018 11:12 am

easyw-fc wrote:
Fri May 04, 2018 9:38 am
3) it seems the A3 build for win is missing ssl libs
easyw-fc wrote:
Fri May 04, 2018 9:38 am
4) 'Addons manager' doesn't work (this is related to point 3)
Copy libeay32.dll and ssleay32.dll from 0.16.6712 will fix these 2. I need to update the libpack used by AppVeyor.
User avatar
easyw-fc
Posts: 2689
Joined: Thu Jul 09, 2015 9:34 am

Re: Assembly3 preview

Postby easyw-fc » Fri May 04, 2018 11:24 am

sgrogan wrote:
Fri May 04, 2018 11:12 am
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
realthunder
Posts: 1229
Joined: Tue Jan 03, 2017 10:55 am

Re: Assembly3 preview

Postby realthunder » Fri May 04, 2018 12:30 pm

easyw-fc wrote:
Fri May 04, 2018 9:38 am
1) after starting FC, if I open a '.py' file, the 'execute macro' button is not enabled and I get the following error:
Noted, and thanks for reporting. I will fix it soon.

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
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.

5) 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.

Image
Try Assembly3 (latest version 0.10.2) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
easyw-fc
Posts: 2689
Joined: Thu Jul 09, 2015 9:34 am

Re: Assembly3 preview

Postby easyw-fc » Fri May 04, 2018 1:57 pm

realthunder wrote:
Fri May 04, 2018 12:30 pm
easyw-fc wrote:
Fri May 04, 2018 9:38 am
1) after starting FC, if I open a '.py' file, the 'execute macro' button is not enabled and I get the following error:
Noted, and thanks for reporting. I will fix it soon.
Thx
realthunder wrote:
Fri May 04, 2018 12:30 pm
easyw-fc wrote:
Fri May 04, 2018 9:38 am
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
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.
I will try to use these info in my code... I still have to fully understand the new context environment. Thx
realthunder wrote:
Fri May 04, 2018 12:30 pm
easyw-fc wrote: 5) 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'.
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
links-Cuts.gif (242.12 KiB) Viewed 453 times
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 ;)
realthunder wrote:
Fri May 04, 2018 12:30 pm
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 also for this :D
Maurice
realthunder
Posts: 1229
Joined: Tue Jan 03, 2017 10:55 am

Re: Assembly3 preview

Postby realthunder » Sat May 05, 2018 12:11 am

easyw-fc wrote:
Fri May 04, 2018 1:57 pm
I will try to use these info in my code... I still have to fully understand the new context environment. Thx
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

Code: Select all

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.
easyw-fc wrote: 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.
Right, I thought I have fixed that. But apparently not. For now, you can work around like this.
Image

easyw-fc wrote:
Fri May 04, 2018 1:57 pm
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..
Exactly, I have that use case in mind long before I started asm3. In fact, even before I started working on Link.
Try Assembly3 (latest version 0.10.2) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
herbk
Posts: 1568
Joined: Mon Nov 03, 2014 3:45 pm
Location: Windsbach, Bavarya (Germany)

Re: Assembly3 preview

Postby herbk » Sat May 05, 2018 6:47 am

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.
Gruß Herbert
User avatar
easyw-fc
Posts: 2689
Joined: Thu Jul 09, 2015 9:34 am

Re: Assembly3 preview

Postby easyw-fc » Sat May 05, 2018 7:21 am

herbk wrote:
Sat May 05, 2018 6:47 am
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
Last edited by easyw-fc on Sat May 05, 2018 7:41 am, edited 1 time in total.
Mark Szlazak
Posts: 407
Joined: Tue Apr 04, 2017 6:06 pm
Location: Edmonton, Canada

Re: Assembly3 preview

Postby Mark Szlazak » Sat May 05, 2018 7:22 am

When will Assembly 3 be part of FreeCAD Daily builds? A lot more will test it out when this happens.
Turro75
Posts: 170
Joined: Mon Aug 15, 2016 10:23 pm

Re: Assembly3 preview

Postby Turro75 » Sat May 05, 2018 9:12 am

sgrogan wrote:
Fri May 04, 2018 11:12 am
easyw-fc wrote:
Fri May 04, 2018 9:38 am
3) it seems the A3 build for win is missing ssl libs
easyw-fc wrote:
Fri May 04, 2018 9:38 am
4) 'Addons manager' doesn't work (this is related to point 3)
Copy libeay32.dll and ssleay32.dll from 0.16.6712 will fix these 2. I need to update the libpack used by AppVeyor.
realthunder wrote:
Wed May 02, 2018 10:52 pm
Turro75 wrote:
Wed May 02, 2018 9:35 pm
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.

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?