Assembly 4 workbench

Using the https://github.com/Zolko-123/FreeCAD_Examples/blob/master/Asm4_Tutorial2/asm_tuto2.FCStd file, I ran the animation and saved a MP4 file without deviating from the standard steps.

as bernard’s picture. Click on save->open the pop up error message box.

Precision
After installing the opencv-4.8.1-windows.exe file here
C:\Users\AppData\Roaming\FreeCAD\Mod
There are 2 files Init.py and not Init_Gui.py located here
C:\Users\berna\AppData\Roaming\FreeCAD\Mod\opencv\build\python
C:\Users\berna\AppData\Roaming\FreeCAD\Mod\opencv\sources\modules\python\package
I had to add the line
sys.path.insert(1, ‘C:/opencv-4.8.1-windows/opencv/build/python’)
I performed this operation on only 1 file at first and seeing that this did not bring any improvement after opening ASM4 I did the same operation on the 2nd file.

__

I appreciate English is not your first language and I tried my best to make the instructions as simple as possible. At no stage did I advise copying the opencv folder into C:\Users\berna\AppData\Roaming\FreeCAD\Mod so please remove them as they are just confusing the situation. I asked for you to nominate a workbench that you don’t upgrade very often. If you upgrade all of them regularly which is perfectly reasonable then why not install Plot workbench just for this purpose and then edit the Init_Gui.py in Plot subfolder as advised and add

sys.path.insert(1, 'C:/opencv-4.8.1-windows/opencv/build/python').

after the import os, sys

When you are complete and restarted FreeCAD carry out this additional step in the Python Console:

import cv2
cv2.__file__

In your case the output should be C:/opencv-4.8.1-windows/opencv/build/python because that is the location that I advised the exe file should be extracted to.

Thanks
So I deleted the directory generated under
C:\Users\AppData\Roaming\FreeCAD\Mod
and I installed opencv here
C:\Users\berna\AppData\Local\Programs
After opening FreeCAD and launching the instructions in Python
import cv2
cv2.file
I get this
Capture d’écran 2023-12-23 172439.png
Recording animation still not working

Bernard19 You obviously need someone who speaks French so I’m sorry I can’t help any further.

Syres I opened a post on the French freeCAD forum
https://devtalk.freecad.org/t/résolu-asm4-opencv-ou/74617/1
Happy Holidays

Vincent B this might apply to your situation but it’s come to my notice that there’s two ways to extract the downloaded file, I use 7-Zip and extract to the folder of the same name as the file but if the user just double-clicks the exe and extracts to C:\ then the folder structure is different.

Therefore I’ve wrote a batch file (below) which can be placed anywhere on any hard drive, call it Setup_cv.bat for example. The idea is to have a workbench that will start before Assembly4 though this really shouldn’t be necessary.

It will look for the two different folder structures on C: and if it finds one then it will create a mini workbench and populate the InitGui.py automatically, all you need to do is start FreeCAD after it’s completed (it’s very fast so blink and you’ll miss it). If this still doesn’t work then I give up, this is getting way too complex IMHO.

@echo off
REM ***************************************************
REM ******  S      T       A        R         T  ******
REM ***************************************************
if exist %HOMEDRIVE%\opencv\build\python goto :Build
if exist %HOMEDRIVE%\opencv-4.8.1-windows\opencv\build\python goto :Build2
echo ***** %HOMEDRIVE%\opencv\build\python does not exist                      ******
echo ***** neither does %HOMEDRIVE%\opencv-4.8.1-windows\opencv\build\python   ******
echo ***** therefore terminating                                      ******
goto :End

:Build
set cv2_location=%HOMEDRIVE%/opencv/build/python
goto :Main

:Build2
set cv2_location=%HOMEDRIVE%/opencv-4.8.1-windows/opencv/build/python
goto :Main

:Main
%HOMEDRIVE%
cd%HOMEPATH%\AppData\Roaming\FreeCAD\Mod
mkdir 1_cv2
cd 1_cv2
echo def runStartupMacros(name): > %APPDATA%\FreeCAD\Mod\1_cv2\InitGui.py
echo     # Do not run when NoneWorkbench is activated because UI isn't yet completely there >> %APPDATA%\FreeCAD\Mod\1_cv2\InitGui.py
echo     if name != "NoneWorkbench": >> %APPDATA%\FreeCAD\Mod\1_cv2\InitGui.py
echo         # Run macro only once by disconnecting the signal at first call >> %APPDATA%\FreeCAD\Mod\1_cv2\InitGui.py
echo         FreeCADGui.getMainWindow().workbenchActivated.disconnect(runStartupMacros) >> %APPDATA%\FreeCAD\Mod\1_cv2\InitGui.py
echo         import sys >> %APPDATA%\FreeCAD\Mod\1_cv2\InitGui.py
echo         sys.path.insert(1, '%cv2_location%') >> %APPDATA%\FreeCAD\Mod\1_cv2\InitGui.py
echo import __main__ >> %APPDATA%\FreeCAD\Mod\1_cv2\InitGui.py
echo __main__.runStartupMacros = runStartupMacros >> %APPDATA%\FreeCAD\Mod\1_cv2\InitGui.py
echo: >> %APPDATA%\FreeCAD\Mod\1_cv2\InitGui.py
echo FreeCADGui.getMainWindow().workbenchActivated.connect(runStartupMacros) >> %APPDATA%\FreeCAD\Mod\1_cv2\InitGui.py
cd%HOMEPATH%
echo *****  Created special startup workbench called 1_cv2 which starts before Assembly4 *****
:End

I just loaded the stable version of freecad 0.21.1
and surprisingly, the animation recording works.

Hi,

I need help. I want to edit a component’s sketch dimension inside an assembly, but after:

  • editing in place the sketch (inside the assembly)
    updating,
    saving all files
    close all files
    reopening the whole assembly

the file inside the assembly appears as it originally was as well as if I open the original file too.

How can I manage it?

Thx.

Michele

I have just noticed an inconsistency in the menus offered when creating an LCS.
The Assembly directory is selected,
click on the LCS icon > New Coordinate System > OK
1st case
The attachment window appears with a certain number of suggestions.
2nd case
click on the LCS icon > OK
the attachment window appears with a certain number of suggestions instead of OK > Cancel
To open the attachment window again, I click on the 3 small points of the LCS Attachment/Map Mode and there the proposal is different from the first. The Z tangent to edge option is different in this case from the first.
The operation between the two is different
Is this normal?

OS: Windows 11 build 22631
Word size of FreeCAD: 64-bit
Version: 0.22.0dev.35485 (Git)
Build type: Release
Branch: main
Hash: a662fbb2ff267fb8dd56fcc3d1ec55a5968b7f5a
Python 3.10.13, Qt 5.15.8, Coin 4.0.2, Vtk 9.2.6, OCC 7.6.3
Locale: French/France (fr_FR)
Installed mods:
* Assembly4 0.50.6

I use both methods frequently and have not seen any functional differences.

What are some best practices to work around the topological naming problem (TNP) when using Assembly 4? Specifically, on where to attach LCSs.

I’m still a beginner, and I thought I took great care to avoid the TNP when creating the individual parts of an assembly. Only to realize my assembly is affected by it, as the LCSs I add to individual parts are attached to generated geometry. Window assembly file I’m working on, as an example.

Zolko
This report of a suspected bug has to do with in-context design using Assembly4. I do not know if this is related to Assembly4 or a general problem with FreeCAD links. We seem to have lost the ability to assemble an empty body to another body LCS, select the link, add a PartDesign sketch, and begin design at that LCS origin. The sketch opens at the global or assembly origin. It has to be closed and re-opened for it to properly locate to its assembled LCS.

The image shows what I would like to achieve:

link_sketch_bug.jpg

It seems this anomaly was introduced sometime after V0.20 release where it functions properly:

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.1.29410 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: f5d13554ecc7a456fb6e970568ae5c74ba727563
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods: 
  * Assembly4 0.50.6
  * fasteners 0.4.15
  * freecad.gears 1.1.0
  * QuickMeasure 2022.10.28

It does not function as intended after V0.21 stable or with my current V0.22:

OS: Windows 11 build 22621
Word size of FreeCAD: 64-bit
Version: 0.22.0dev.35510 (Git)
Build type: Release
Branch: main
Hash: da05f7c8e8b25ff783cc6c4eb3b73b640f134519
Python 3.10.13, Qt 5.15.8, Coin 4.0.2, Vtk 9.2.6, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods:

  • Assembly4 0.50.6
  • fasteners 0.4.15
  • freecad.gears 1.1.0
  • QuickMeasure 2022.10.28

(IIRC it was OK at V0.21.0.33263 when I was designing this assembly:https://devtalk.freecad.org/t/pd-v021asm4-0502-reverse-engineering-the-f16-main-landing-gear/70163/1)

Steps to reproduce the bug using Assembly4:

  1. Create an empty Assembly4 Body
  2. Insert the body into the assembly and attach it another body using an LCS not located at the assembly origin.
  3. Double click the body link which takes you to PartDesign and add a sketch.
  4. It does not open at the proper LCS location. It opens at the assembly or global origin.
  5. Close the sketch. It jumps to the intended LCS location! Now, you can reopen the sketch and proceed with in-context design work.

Needless to say, this is a great annoyance when modelling in context of the assembly.

Can anyone else confirm?
And, should I also report this in the Open Discussion group?

Do not attach LCS or hole axes to feature edges or vertices. Rather, attach them only to origin planes or to the sketch that creates the feature that locates the body in the assembly. That will drastically minimize but not eliminate TNP. It can still be a problem if you change the sketch to the point where its edges or vertices get renumbered. I.e. you cannot go back and add, subtract, or convert an edge to construction geometry after you have attached an LCS. You can generally make reasonable changes to dimensions but not other constraints.

I would also encourage you to use the Assembly4 Body rather than the PartDesign body since the former will include an LCS attached to the bodies origin which you can use for assembly. Pay attention where you create the first sketch which should be at the feature which locates the body in the assembly. With a little practice this becomes a great time saver and makes most assemblies a seamless experience with no TNP issues.

I can confirm, and it seems to be a Sketcher bug, not Asm4. When following your example and creating a new sketch, the Sketcher opens in the wrong attachment position, and it’s not even possible to draw anything into the sketch! If I delete Sketch001 in Body_003, an try to re-create it, the new sketch indeed opens in a weird attachment position, but additionally I cannot draw anything in the Sketcher with mouse until I rotate the View or restart the Sketcher. If I try to draw for example a circle, then nothing is created, the cursor changes to default arrow, and there’s no error message. However, if I rotate the view even slightly in any direction, then drawing becomes possible. Seems to me that something about the attachment position is either left uninitialized or in null/error position in the Sketcher, and rotating the view direction fixes this. Definitely should be reported in the open forum.


OS: Windows 10 build 19045
Word size of FreeCAD: 64-bit
Version: 0.22.0dev.35554 (Git)
Build type: Release
Branch: main
Hash: 8e2ab9f76888ac4da971f9d5069cec7bcc2b572f
Python 3.10.13, Qt 5.15.8, Coin 4.0.2, Vtk 9.2.6, OCC 7.6.3
Locale: English/United Kingdom (en_GB)
Installed mods: 
  * Assembly4 0.50.6
  * Curves 0.6.21
  * Defeaturing 1.2.1
  * fasteners 0.4.75
  * FCGear 1.0.0
  * freecad.gears 1.0.0
  * Manipulator 1.5.5
  * OpticsWorkbench 1.0.10
  * OpticsWorkbench.backup1703674786.9866414 1.0.9 (Disabled)
  * QuickMeasure 2022.10.28
  * Reinforcement
  * Render 2023.8.18
  * sheetmetal 0.3.13
  * ThreadProfile 1.89.0
  * toSketch 1.0.1

Thanks for taking the time to confirm. I tend to agree that it is not limited to Assembly4. You get the same unwanted behavior if you create a link to an empty body in PartDesign, change its placement properties, and add a sketch. The sketch opens at the global origin rather than the body origin. If you close and reopen it is located properly.

I do not see any of this behavior but am not running the later version 35554 as you are.

I will report in Open Discussion and reference these posts.

Thank you for sharing these best practices. This is really helpful.

I feel I must be doing something wrong or not understanding the concept. If I attach the LCS to the origin planes, I then have to calculate and set their Attachment Offset’s x, y and z coordinates manually to get them where I want them.

This would add a significant amount of time to put together the assembly. I’m already spending more time setting up LCSs attached to vertices (wrong, I know, but it’s a relatively quick point-and-click operation) than actually designing the individual parts. That would increase the time spent on assembly significantly.

If I now switch from that method to setting individual offsets of LCS attached to the origin, I might as well not use an assembly workbench and offset and place the original parts instead.

Here’s an LCS set by AttachmentOffset now on that file, which originally was attached to a vertex
Captura de pantalla de 2024-01-10 19-46-21.png
I’m just trying to understand it better, so any input is really welcome. Thanks!

I should have been more clear. It is such a habit with me that I forget about the details.

What I wanted to convey is that the body LCS should be attached to the Body origin plane which is automatic if you use the Assembly4 body. When you assemble this body it will locate itself at the location of the LCS to which you are attaching. If you have to add any LCS’s to this body for attaching other bodies during assembly, then attach them to the parent body sketches which of course reference the body origin and the LCS used to place it in the assembly.

Zolko recommends using a skeleton or master sketch in his documentation for this purpose. I tend to use the feature sketches within the body itself more often. If you add the LCS to the sketch when you add an assembly interface feature (joint) in the body then it almost becomes transparent.

At least that is the way I handle it, but as you know there are many ways of accomplishing the same thing in FreeCAD so it takes some experimentation.
Perhaps Zolko, aapo, or other heavy users of Assembly4 can add some insight or better explanations.

No worries, you were clear enough. I had understood that part, and I appreciate you taking the time to reply. If I got this right: when using the “Create body” option from Assembly 4, I believe the two main advantages are:

  1. It puts the newly created Body inside the Parts group for you, which saves you time.
  2. It creates an LCS attached to the origin plane of the Body. If you can use that to attach to other parts directly, it saves you time as well.

However, if you need to create an LCS at a specific position such as the assembly parts on my model, and not reference generated geometry, you’ll still have to specify the AttachmentOffset. Whether this new LCS is attached to the origin LCS added by Assembly 4, or it is directly attached to the Body’s origin makes no difference. Is this correct?

So I’m wondering whether I should be using datum planes to attach parts instead of coordinate systems.

I’ve also just tried to do that, but I couldn’t find a way to attach an LCS to geometry from a feature’s sketch.

I had seen references to the master sketch, but I failed to find an explanation of what it is or how to implement it. If I understand it correctly, it’s a sketch in the assembly that’s not part of any Body/Part. And the Bodies/Parts to be assembled can be attached to it. Is this correct?

That still leaves me with the question of how to best define the LCSs in the individual Bodies/Parts themselves. Apologies if I’m going in circles, I’m trying to make sure I have a clear understanding of all these concepts, so as not to be able to create solid models without spend an inordinate amount of time on assembly. Thanks.