Assembly 4 workbench

Discussion about the development of the Assembly workbench.
project4
Posts: 185
Joined: Fri Jul 12, 2013 12:53 pm

Re: Assembly 4 workbench

Postby project4 » Sat Sep 12, 2020 6:49 am

realthunder wrote:
Sat Sep 12, 2020 1:59 am
getSubObject() by default return a Shape of the object. To return the object, add an extra argument retType=1. Checkout the docstring of getSubObject() to find out more details.
Thanks. that did the trick.
Unfortunately the API documentation don't have anything on getSubObject :(
The only hint I can get is the pyConsole tooltip...
project4
Posts: 185
Joined: Fri Jul 12, 2013 12:53 pm

Re: Assembly 4 workbench

Postby project4 » Sat Sep 12, 2020 12:33 pm

Hello All,

I have a working code for "Show/Hide LCSs" feature.
Please contribute 2 icons for those features, one for show and one for hide.
I'm not good with graphics...

I imagine it similar to "Create a new coordinate system in a part" icon, one with "V" and one with "X" on it.

Thanks.
louisgag
Posts: 45
Joined: Fri Jan 17, 2020 9:59 am

Re: Assembly 4 workbench

Postby louisgag » Mon Sep 14, 2020 12:30 pm

Hi again,
I'm trying to run Asm4 from my system's python console but am having a hard time figuring out how to call those "Gui" commands without actually loading the Gui itself.
Is that possible? If so, how would one create a newModel() for example?
Tried

Code: Select all

import newModelCmd

Code: Select all

Gui.runCommand('Asm4_newModel',0)
and such but can't get it to work...

Edit: i managed to get around this, but I'm forced to load the Gui window, here's the essence of my approach:

Code: Select all

import sys
sys.path = ['...a lot of paths...']
import FreeCAD, FreeCADGui
FreeCADGui.showMainWindow()
FreeCADGui.activateWorkbench("Assembly4_WorkBench")
FreeCAD.newDocument("testASM4model")
Gui.runCommand('Asm4_newModel',0)
from what I read around I think the chances that I can work with a workbench (here Assembly4) without loading the Gui or "adapting" the whole code of the workbench manually are somewhat null because most functions are coded as python classes which are only callable from the Gui commands... please correct me if I'm wrong!
User avatar
Zolko
Posts: 1007
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly 4 workbench

Postby Zolko » Mon Sep 14, 2020 10:36 pm

louisgag wrote:
Mon Sep 14, 2020 12:30 pm
please correct me if I'm wrong!
No, you're right: Assembly4 can only be used with the Gui active.
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
vocx
Posts: 5068
Joined: Thu Oct 18, 2018 9:18 pm

Re: Assembly 4 workbench

Postby vocx » Mon Sep 14, 2020 10:57 pm

louisgag wrote:
Mon Sep 14, 2020 12:30 pm
...
from what I read around I think the chances that I can work with a workbench (here Assembly4) without loading the Gui or "adapting" the whole code of the workbench manually are somewhat null because most functions are coded as python classes which are only callable from the Gui commands...
Correct.

Unless the workbench provides a specific non-GUI programming interface, most workbenches can only be used by loading the graphical user interface. Other workbenches, like Draft and FEM, provide functions that you can call from the Python console, so in theory you could create many objects without the interface, just by running a script.

What you want has also been asked of the A2plus Workbench, and I've given the same response, it cannot be used from the terminal only.

Updating A2Plus objects by script

In order to improve this situation we would need to abstract the operations of the workbench, and place them in small functions that just perform a single action (create a model, add a part, move the part, add an attachment, etc.). I believe this is possible as most operations in 3D space can be defined mathematically without using the GUI, but it's hard work that somebody should do.
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.
louisgag
Posts: 45
Joined: Fri Jan 17, 2020 9:59 am

Re: Assembly 4 workbench

Postby louisgag » Wed Sep 16, 2020 9:14 am

Thanks for you explanations!
The best I could achieve is to hide the main window right after loading it.

Code: Select all

Gui.getMainWindow().hide()
Working directly from my Python console still remains limiting and I'll give that up because in the end I'm only trying to parametrize a few variables that define the parts and assembly sketches used in my assembly.
HK sxx
Posts: 58
Joined: Mon Apr 20, 2020 5:32 pm

Re: Assembly 4 workbench

Postby HK sxx » Wed Sep 16, 2020 5:31 pm

Hello,

I'm having a hard time with carbon copies in Assembly 4. I don't know if I do something wrong or something fails.
When making a sketch in a body I can't make a carbon copy of the other scketh which actually resides in the Model (asm) container of the tree.

One easy sequence would be:
1> Create a New Assembly4 Model
2> Create two sketchs, one inside the Model container and other outside.
3> Create a new body and activate (Part Design)
4> Create a new sketch (inside the body) in order to make the carbon copy of the other sketches.
5> Now, in said sketch edition, clicking the carbon copy button and hold Ctrl, allow selection of sketch outside but not of sketch inside the Model.
test_CC.png
test_CC.png (99.83 KiB) Viewed 342 times
Any advice would be well received.
Attached test file.
Thank you.

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22411 (Git)
Build type: Release
Branch: master
Hash: d4519d5aec15bc08f029da5ed15410a494b57b2c
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Spanish/Spain (es_ES)
Attachments
test_CC.FCStd
(14.89 KiB) Downloaded 3 times
louisgag
Posts: 45
Joined: Fri Jan 17, 2020 9:59 am

Re: Assembly 4 workbench

Postby louisgag » Wed Sep 16, 2020 7:54 pm

I can confirm the behavior when using your example file.
What you can do is move the body into the model and the "in" sketch into the body.
Then you will be able to carbon copy from both "in" and "out" into the CC sketch
HK sxx
Posts: 58
Joined: Mon Apr 20, 2020 5:32 pm

Re: Assembly 4 workbench

Postby HK sxx » Wed Sep 16, 2020 8:11 pm

louisgag wrote:
Wed Sep 16, 2020 7:54 pm
I can confirm the behavior when using your example file.
What you can do is move the body into the model and the "in" sketch into the body.
Then you will be able to carbon copy from both "in" and "out" into the CC sketch

Thanks for your answer but Still I am not be able to carbon copy when I move all into the model.

Moreover, I think the workflow would not be correct because the body link is entered, not the body itself.
Last edited by HK sxx on Thu Sep 17, 2020 4:31 am, edited 1 time in total.
louisgag
Posts: 45
Joined: Fri Jan 17, 2020 9:59 am

Re: Assembly 4 workbench

Postby louisgag » Wed Sep 16, 2020 8:18 pm

For me it works as I described on 0.19-daily.
Its obviously just a workaround solution.
As for the workflow you have to see for yourself...