Assembly4 and TechDraw

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
wandererfan
Veteran
Posts: 6308
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Assembly4 and TechDraw

Post by wandererfan »

I am working on making drawings from assemblies. Currently I am working with the Assembly4 model from this post:
https://www.forum.freecadweb.org/viewto ... 10#p341631.
asm_tuto12-one_file.png
asm_tuto12-one_file.png (38.24 KiB) Viewed 6348 times
The Model object is an App::Part, but it has a Shape property.

Code: Select all

>>> m = App.ActiveDocument.Model
>>> m
<Part object>
>>> m.Shape
<Compound object at 0x55b83ee12540>
>>> m.Group
[<group object>, <Part::PartFeature>, <App::Link object>, <App::FeaturePython object>, <App::Link object>, <App::FeaturePython object>, <App::Link object>, <App::FeaturePython object>, <App::Link object>, <App::FeaturePython object>]
This is the first time I've encountered a Part that has a Shape. Usually I hunt through the Group (and children) for objects with a Shape.

Is this Shape added by Assembly4? Does it represent the whole assembly? Do "Model" objects always have a Shape?
Is objectName == "Model" a reliable indicator that the object is an assembly?

Thanks,
wf
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Assembly4 and TechDraw

Post by vocx »

wandererfan wrote: Fri Oct 25, 2019 3:20 pm ...
This is the first time I've encountered a Part that has a Shape.
...
Maybe this gives you a bit of insight, Why does App::MaterialObjectPython needs a Shape?

As I understand, with the LinkMerge, realthunder made it so that every DocumentObject in FreeCAD has a Shape. But then he changed the logic a bit so that only valid objects would have a Shape.

So it could be two possibilities, that what you see is due to the LinkMerge or that this is exclusive to Assembly4.
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.
kbwbe
Veteran
Posts: 1052
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Assembly4 and TechDraw

Post by kbwbe »

wandererfan wrote: Fri Oct 25, 2019 3:20 pm This is the first time I've encountered a Part that has a Shape. Usually I hunt through the Group (and children) for objects with a Shape.

Is this Shape added by Assembly4? Does it represent the whole assembly? Do "Model" objects always have a Shape?
Is objectName == "Model" a reliable indicator that the object is an assembly?

Thanks,
wf
Part containers now seem to have a shape. As Assembly4 is using a Part container with name "Model" it has a shape too. I registered this some days ago when i got problems during import of docs to A2+.
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.56, installable via FreeCAD's addon manager
Tutorial: gripper assembly https://www.youtube.com/watch?v=QMxcQ5tssWk
Documentation: https://www.freecadweb.org/wiki/A2plus_Workbench
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly4 and TechDraw

Post by Zolko »

wandererfan wrote: Fri Oct 25, 2019 3:20 pm Is this Shape added by Assembly4? Does it represent the whole assembly? Do "Model" objects always have a Shape?
an Assembly4 'Model' is an App::Part named at creation time 'Model'. Also at creation a coordinate system is added, because that's what Assembly4 uses. And it's this coordinate system (PartDesign::CoordinateSystem) that has a shape. So a standard App::Part will not have a shape by default, but an Assembly4 Model will always have a shape.

wandererfan wrote: Fri Oct 25, 2019 3:20 pm Is object.Name == "Model" a reliable indicator that the object is an assembly?
if object.TypeId == "App::Part" also then yes, that was the intent. The thinking was that nobody else will create App::Part objects named "Model".
try the Assembly4 workbench for FreCAD — tutorials here and here
aapo
Posts: 617
Joined: Mon Oct 29, 2018 6:41 pm

Re: Assembly4 and TechDraw

Post by aapo »

wandererfan wrote: Fri Oct 25, 2019 3:20 pm I am working on making drawings from assemblies. Currently I am working with the Assembly4 model from this post:
That's great news! I'm already using TechDraw with Assembly4, and there certainly are some oddities:
  • Usually TechDraw draws everything under an Assembly4 assembly "model", but if some bodies within the models or submodels are not visible (Visible = false), they are not drawn in TechDraw for some reason.
  • If you select one model, and try to make a TechDraw drawing of it, then TechDraw actually draws to whole assembly model, at least for me.
  • I work around the abovementioned problem by making everything invisible except the selected bodies for my drawing, which is a bit clumsy, but works.
  • However, if you update or load a drawing made by that way, the drawn TechDraw bodies reflect the visibility situation at refresh moment, which basically scrambles the drawings pretty badly.
The Good News (tm) is that it already kind of works! :D
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly4 and TechDraw

Post by Zolko »

aapo wrote: Sat Oct 26, 2019 9:16 pm
  • Usually TechDraw draws everything under an Assembly4 assembly "model", but if some bodies within the models or submodels are not visible (Visible = false), they are not drawn in TechDraw for some reason.
that seems quite logical to me. And also the same as other CAD systems. What behaviour would you want ?

aapo wrote: Sat Oct 26, 2019 9:16 pm
  • However, if you update or load a drawing made by that way, the drawn TechDraw bodies reflect the visibility situation at refresh moment, which basically scrambles the drawings pretty badly.
Yeah, this begs the feature to have "states" or "configurations" in the assembly: stored and named lists of the assembly's parts to show/hide, and that can be triggered at will. I'd add something that you didn't yet ask-for but that you will: to include in these "configurations" not only show/hide options for each part, but also different Placement properties for their AttachmentOffsets: this will allow to make exploded views of assemblies, which allows to make user and service manuals.

I don't know yet when and how I could implement this. Any ideas/suggestions on how to do this are welcome.
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
wandererfan
Veteran
Posts: 6308
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Assembly4 and TechDraw

Post by wandererfan »

Zolko wrote: Sat Oct 26, 2019 9:04 pm an Assembly4 'Model' is an App::Part named at creation time 'Model'. Also at creation a coordinate system is added, because that's what Assembly4 uses. And it's this coordinate system (PartDesign::CoordinateSystem) that has a shape. So a standard App::Part will not have a shape by default, but an Assembly4 Model will always have a shape.
Thanks for this information.

The LCS definitely has a shape - a Face in the case of LCS_0001. Model also has a somewhat oddly behaved Shape property that contains the whole assembly.

Code: Select all

>>> lcs = App.ActiveDocument.LCS_0001
>>> lcss = lcs.Shape
>>> lcss
<Face object at 0x55bc44ec2490>

>>> m = App.ActiveDocument.Model
>>> m.Shape
<Compound object at 0x55bc438c5020>
>>> ms = m.Shape
>>> Part.show(ms)             <<<<< displays whole assembly

>>> m.getPropertyByName("Shape")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: Property container has no property 'Shape'
>>> 
So we have an App::Part which has a Shape property, but the Shape is "semi-hidden". It can not be accessed directly in C++ since App::Part has no member "Shape". It can be accessed in Python, but not by Name, and doesn't appear in the property drop down in the Python console.
User avatar
wandererfan
Veteran
Posts: 6308
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Assembly4 and TechDraw

Post by wandererfan »

aapo wrote: Sat Oct 26, 2019 9:16 pm Usually TechDraw draws everything under an Assembly4 assembly "model", but if some bodies within the models or submodels are not visible (Visible = false), they are not drawn in TechDraw for some reason.
There is nothing in TD to include/exclude components based on visibility. We draw whatever Shape the Source object(s) provides. In the case of a Body, there are many invisible components that are not included in the Body's Tip shape (Sketches, Origin, earlier PartDesign::Features, etc).

At first glance, it doesn't seem unreasonable for the Source to only provide the Visible bits to TD.
aapo wrote: Sat Oct 26, 2019 9:16 pm [*]If you select one model, and try to make a TechDraw drawing of it, then TechDraw actually draws to whole assembly model, at least for me.
[*]I work around the abovementioned problem by making everything invisible except the selected bodies for my drawing, which is a bit clumsy, but works.
Recently, I have seen something like this with Arch Groups. If a subcomponent within the Group is selected as Source for a TDView, the selection morphs into the whole Group.
aapo wrote: Sat Oct 26, 2019 9:16 pm [*]However, if you update or load a drawing made by that way, the drawn TechDraw bodies reflect the visibility situation at refresh moment, which basically scrambles the drawings pretty badly.
Don't see a work around for this right now.
aapo
Posts: 617
Joined: Mon Oct 29, 2018 6:41 pm

Re: Assembly4 and TechDraw

Post by aapo »

wandererfan wrote: Sun Oct 27, 2019 12:33 pm Don't see a work around for this right now.

Well, there is a workaround on the assembly side of the process (and I think it's also the suggested way to organize things in FreeCAD assemblies in general): Build your model so that every sub-assembly is in its own .FCStd file. So, you'll have your own files for each of the bodies, each of the 2nd level sub-assemblies, etc, and finally a main assembly. That way you can TechDraw a sub-assembly by opening just this one file alone, and it will auto-load just the sub-sub-assemblies it needs, but does not see nor auto-load geometry from models higher in the tree (nor at the same level). You'll only run into problems, if you want, for some reason, to make TechDraw drawings of parts in a different way than your model is organized, but why would you want to do that?

I guess there should be some kind of a tutorial for this kind of Asm4-TechDraw workflow, because at the moment it seems you'll easily get into annoying problems making assembly pics with TechDraw, because the link merge and assembly technologies are still quite young. Of course, when the development advances on this front, too, many other different ways to achieve good results easily may become possible.
aapo
Posts: 617
Joined: Mon Oct 29, 2018 6:41 pm

Re: Assembly4 and TechDraw

Post by aapo »

Zolko wrote: Sun Oct 27, 2019 12:04 pm Yeah, this begs the feature to have "states" or "configurations" in the assembly: stored and named lists of the assembly's parts to show/hide, and that can be triggered at will. I'd add something that you didn't yet ask-for but that you will: to include in these "configurations" not only show/hide options for each part, but also different Placement properties for their AttachmentOffsets: this will allow to make exploded views of assemblies, which allows to make user and service manuals.

I don't know yet when and how I could implement this. Any ideas/suggestions on how to do this are welcome.
I like this idea a lot, especially the possibility to do exploded views. I can already imagine a macro that pushes the LCS coordinates on a given axis by a constant amount. With the LCS:s the obvious way would be to put all the LCS into a "states" container, where you'd have LCS0_state0, LCS0_state1, etc. for all the LCS:s of the model. Then, the LCS0 in the model would just be a link to the LCS0_state0 in the "states" container, and you'd change the state by changing the link to point to a different one in the states container. So, normally you'd have just "state0" LCS:s, but after running your explode macro you'd have "state1" LCS:s there, too. Of course, you'd need an efficient way to select between the states, too.
Post Reply