I believe this has been reported before and is because of a Python's peculiarity. It has not been fixed yet: https://github.com/FreeCAD/FreeCAD/issues/7020PAS_Drafter wrote: ↑Tue Mar 28, 2023 6:02 amYou are right about that. I had seen that a while back myself that if you name something with a number as the first character, Assembly 4 does not like that for some reason. I've just made it a point not to start with numbers
I've attached a sample file that shows the issue. Notice that when you try to insert the part the list gets messed up.
I've added this to the bug list. #418
Assembly 4 workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Assembly 4 workbench
-
- Posts: 339
- Joined: Mon Aug 02, 2021 6:29 am
- Location: California, USA
Re: Assembly 4 workbench
I had never experienced this outside of Assembly 4 so did not think to look in the general bugs. Thanks for letting me know.Lonfor wrote: ↑Tue Mar 28, 2023 6:54 am I believe this has been reported before and is because of a Python's peculiarity. It has not been fixed yet: https://github.com/FreeCAD/FreeCAD/issues/7020
Re: Assembly 4 workbench
Not exactly a python peculiarity, usually it is a well assessed habits to not start variable names with numbers, see below after @wmayer quote.Lonfor wrote: ↑Tue Mar 28, 2023 6:54 am ...
I believe this has been reported before and is because of a Python's peculiarity. It has not been fixed yet: https://github.com/FreeCAD/FreeCAD/issues/7020
See maybe in this discussion why C and C++ as example have this convention:The file name is used as an identifier and because the first character cannot be a digit (not even in Py3) it will be replaced with an underscore. See also: https://docs.python.org/3/reference/lex ... dentifiers:
Within the ASCII range (U+0001..U+007F), the valid characters for identifiers are the same as in Python 2.x: the uppercase and lowercase letters A through Z, the underscore _ and, except for the first character, the digits 0 through 9.
https://softwareengineering.stackexchan ... h-a-number
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Assembly 4 workbench
I understand that. But is a file name a variable or just a characters' stream? I ask this from my lowly understanding of cpp.
And if different streams (file names) are in fact turned into variables by the program's logic, I suppose it must be a trick to show the unchanged original characters' stream in the GUI.
Re: Assembly 4 workbench
It is a variable name, as it is used internally, and take in account that some filesystem have also strict rules.
You could prepend a underscore as suggested on some programming forum to circumvent C C++ limitations.
But honestly why complicate code for such a irrelevant thing?
There are already too much quirks about different OS to bother with a such little limitation.
Someone has to maintain code, I trust in they judgement, as they are doing a good work in maintaining the only OpenSource 3D CAD around, simply there are no competitor to FreeCAD, if you search around if you see that possible competitor are far behind.
But as said it is my personal user preference as I'm not involved in FreeCAD development, I only bother sometimes developers with reflection and ideas.
Kind regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Assembly 4 workbench
A little problem, when trying to manage complex assemblies.
I use Asm4 to manage complex assemblies,
I have a problem with linked objects. I have to open the file in the script to create the link, and to make the reference to the object in the file.
But when I close the created document, the linked documents remain open, and pollute the treeview.
I have seen many forum discussion about temporary files that probably will autoclose chen I close the assembly FCStd file.
I create the assembly with a script, using some scavenged code from Assembly4 sources.
I use this code to make the Link.
There is a better way to script Asm4 WB?
There are some code to analyze and see some examples?
I have found this thread:
viewtopic.php?p=359456#p359456
but I could not guess a better way, and probably it could solve only partially my problem (but learning thow to use VariantLink will be very interesting. )
tested on:
Regards
Carlo D.
I use Asm4 to manage complex assemblies,
I have a problem with linked objects. I have to open the file in the script to create the link, and to make the reference to the object in the file.
But when I close the created document, the linked documents remain open, and pollute the treeview.
I have seen many forum discussion about temporary files that probably will autoclose chen I close the assembly FCStd file.
I create the assembly with a script, using some scavenged code from Assembly4 sources.
I use this code to make the Link.
Code: Select all
def createLink(r_Asm, l_Name, l_Obj, at_by, at_to):
"""Create a App::Link."""
obj = r_Asm.newObject('App::Link', l_Name)
obj.LinkedObject = l_Obj
# If the name was already chosen, and a UID was generated:
if obj.Name != l_Name:
# we try to set the label to the chosen name
obj.Label = l_Name
Asm4.makeAsmProperties(obj)
obj.AttachedBy = at_by
obj.AttachedTo = at_to
obj.AssemblyType = "Part::Link"
obj.LinkTransform = False
obj.SolverId = "Asm4EE"
(a_Link, sep, a_LCS) = obj.AttachedTo.partition('#')
if a_Link == 'Parent Assembly':
a_Part = None
else:
a_Part = obj.Document.getObject(a_Link).LinkedObject.Document.Name
l_Part = obj.LinkedObject.Document.Name
if obj.AttachedBy[0] == "#":
l_LCS = obj.AttachedBy[1:]
else:
l_LCS = obj.AttachedBy
expr = Asm4.makeExpressionPart(a_Link, a_Part, a_LCS, l_Part, l_LCS)
# print(expr)
obj.setExpression('Placement', expr)
# update the link
obj.recompute()
return obj
There are some code to analyze and see some examples?
I have found this thread:
viewtopic.php?p=359456#p359456
but I could not guess a better way, and probably it could solve only partially my problem (but learning thow to use VariantLink will be very interesting. )
tested on:
Code: Select all
OS: Artix Linux (openbox)
Word size of FreeCAD: 64-bit
Version: 0.20.2.29603 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 0.20.2)
Hash: 930dd9a76203a3260b1e6256c70c1c3cad8c5cb8
Python 3.10.8, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: Italian/Italy (it_IT)
Installed mods:
* CurvedShapes 1.0.4
* ScriptWB-v1
* QuickMeasure 2022.10.28
* freecad.gears 1.0.0
* Assembly4 0.12.7
* fasteners 0.4.56
* toSketch 1.0.1
* Curves 0.6.8
* Help 1.0.3
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Assembly 4 workbench
popular choice
There are several things here: a link (App::Link) to an object is only a reference to that object, so if an object wants/needs to use it it needs to open the document (file) containing it. It's similar to an symlink. But a document is open in FreeCAD doesn't mean that there is a 3D window open to that document. So what you actually have is that a link (App::Link) to an object needs to open in FreeCAD the document (file) to that object to be able to use it, but FreeCADGui doesn't need to open a GUI to that same document (file).I have a problem with linked objects. I have to open the file in the script to create the link, and to make the reference to the object in the file. But when I close the created document, the linked documents remain open, and pollute the treeview. I have seen many forum discussion about temporary files that probably will autoclose chen I close the assembly FCStd file.
Another completely unrelated subject are temporary hidden documents (files) that hold variantLinks.
In short, I use the single-document view which gives me the most natural handling of open documents/files :
out of curiosity, what exactly are you doing ? I use FreeCAD and Asm4 with the GUI as a traditional 3D CAD software, so I can't really imagine how you use these things. And what you are building with it. Would you gibe some examples ?I create the assembly with a script, using some scavenged code from Assembly4 sources.
Re: Assembly 4 workbench
Tanks for answering.
So it is normal to have linked documents left open.
I note a strange behaviour, but probably is related to the code that is opening them or by some stupid mistake in my python code.
I have the assembly document and the three related "components" file open; I see them on the tabbar under 3dview if I not specify hidden in openDocument() call.
I close these files and then the assembly file, but I have them reappear on the tabbar or be present in the treeview.
What I have not noted is that closing the asm file and then each individual files will have a different behaviour.
Speaking about Variant Link do you have some documentation on them, I need to replicate six parts that differ s only for orientation so I wonder if the use of Variant Link could reduce memory footprint.
It is a complicated assembly that should be animate some part to check interferences, but sadly it is a "reserved" work.
I could however make a MWE soon (in a couple of days) and we could discuss on some less theoretical basis.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Assembly 4 workbench
OK, now I understand. Yes, you probably should set the document to hidden if you open it like that
this is your best bet : viewtopic.php?t=62767Speaking about Variant Link do you have some documentation on them, I need to replicate six parts that differ s only for orientation so I wonder if the use of Variant Link could reduce memory footprint.