Why an object can only be inside one App::Part?

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Why an object can only be inside one App::Part?

Post by realthunder »

Hello, everyone, I just started exploring Part Design, so the question may be dumb. Please bear with me.

Say, I have a screw object, and want 100 instances to put in various places, how can this be achieved using the new App::Part? Using ShapeBinder? From its code I can see that it does simply return the shape from its linked object if no sub element is involved, but it has its own ViewProvider, which means, a change in the base object will trigger an update of all ViewProvider instances. That's obviously not a desired behavior, right? Why can't we just reuse the very same ViewProvider of the object, and simply add a SoTransform node for each instance, and be done with it? And I think Coin3D supports that, right, I mean inserting a node into multiple parents? So, if we put this node sharing thing inside ViewProviderPart, I don't see why can't an object be inside multiple App::Part.

In fact, I can't seem to find any use case of node sharing in FC. Maybe someone tried it and it didn't work? Imaging what if it works, what are the possibilities! Say, let an object appear in multiple documents multiple times with minimum overhead, and I am talking about assemblies, of course. Anyone?
Try Assembly3 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
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Why an object can only be inside one App::Part?

Post by ickby »

This thread should answer all your questions how this is intended to work in the future: https://forum.freecadweb.org/viewtopic.php?f=10&t=17864
Short summary is that there will be Instance objects doing excactly what you describe, but they are not simple to integrate into FreeCAD, hence it may take a while.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Why an object can only be inside one App::Part?

Post by DeepSOIC »

(ickby was faster)
Hi!
This functionality is essentially missing at the moment.
There is a plan for generic Instance object, which will probably work very much like you suggest. In fact, I can probably easily roll one in python. Dealing with selection is an interesting problem. If you feel like it, I invite you to join the efforts to bring this stuff to life.

See this thread (attention: long!)
https://forum.freecadweb.org/viewtopic.php?t=17864

Also, ickby has some code in his local branch. And with your speed, it feels like you may render it obsolete very quickly :mrgreen: .
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Why an object can only be inside one App::Part?

Post by realthunder »

Very informant read. I am only half through the thread. So far, I am with DeepSOIC. And I'd propose promoting ShapeBinder to be the missing link, i.e. to provide a lightweight clone of the object. I'll play with it once I got time.
Try Assembly3 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
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Why an object can only be inside one App::Part?

Post by DeepSOIC »

I think I managed to pull ickby to my side, so to say :mrgreen:
realthunder wrote:And I'd propose promoting ShapeBinder to be the missing link, i.e. to provide a lightweight clone of the object. I'll play with it once I got time.
I'm not quite sure what are you proposing. Please explain in more detail. Do you want Shapebinder to become Instance?
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Why an object can only be inside one App::Part?

Post by realthunder »

DeepSOIC wrote:I'm not quite sure what are you proposing. Please explain in more detail. Do you want Shapebinder to become Instance?
Yes, to be the instance. However, after a close look at its source code, I think I'd better write a brand new feature and viewprovider for proof of concept. The feature is simple, just a PropertyLink to a single child DcoumentObject, feature recomputation shall be minimized, and the ViewProvider shall just borrow the child's node with customized transformation for rendering. If node sharing works as I expected, then there is no need to mess with selection, it will just work as if they were separate entities.
Try Assembly3 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
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Why an object can only be inside one App::Part?

Post by DeepSOIC »

Great! looking forward to experiment with it.
With selection, for assembly purposes we need to know, what subelement of what object was selected, and through which instances. Selecting instance as a whole won't do. Selecting "Edge1" of instance is probably not useful, as there is no way to look up where that edge actually is.

Any thoughts on array support inside instances?
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Why an object can only be inside one App::Part?

Post by yorik »

Just for the record, I am also playing with these concepts:

https://forum.freecadweb.org/viewtopic.php?f=23&t=21144
https://forum.freecadweb.org/viewtopic.php?f=23&t=20933

It is perfectly possible to copy over a node from one object to another, it works quite well, even the selection mechanism (selecting the "copied" node selects the correct object). In fact it is very hard to see that it is not a "real" shape in the 3D view...
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Why an object can only be inside one App::Part?

Post by realthunder »

DeepSOIC wrote:Selecting "Edge1" of instance is probably not useful, as there is no way to look up where that edge actually is.
Whole object selection should be trivial to support. Subelement selection may need some work, or maybe trivial, too. I need to experiment first. What do you mean by selecting "Edge1" is not enough? If you know which instance, which sub element, what more do you want?
DeepSOIC wrote:Any thoughts on array support inside instances?
How about a special group object exposing the same properties as the current draft array, that will auto generate an array of instances as its children with their placement set to read only?
Try Assembly3 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
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Why an object can only be inside one App::Part?

Post by realthunder »

yorik wrote:Just for the record, I am also playing with these concepts:

https://forum.freecadweb.org/viewtopic.php?f=23&t=21144
https://forum.freecadweb.org/viewtopic.php?f=23&t=20933

It is perfectly possible to copy over a node from one object to another, it works quite well, even the selection mechanism (selecting the "copied" node selects the correct object). In fact it is very hard to see that it is not a "real" shape in the 3D view...
Wow, the "Hire" thing is very similar to my idea. Darn it, someone beats me to it :D
Try Assembly3 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
Post Reply