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!
realthunder
Posts: 1540
Joined: Tue Jan 03, 2017 10:55 am

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

Postby realthunder » Fri Mar 24, 2017 8:40 pm

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 (latest version 0.11) along 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
Posts: 2959
Joined: Wed Oct 05, 2011 7:36 am

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

Postby ickby » Fri Mar 24, 2017 8:54 pm

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
Posts: 7600
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

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

Postby DeepSOIC » Fri Mar 24, 2017 8:55 pm

(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
Posts: 1540
Joined: Tue Jan 03, 2017 10:55 am

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

Postby realthunder » Sat Mar 25, 2017 3:20 am

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 (latest version 0.11) along 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
Posts: 7600
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

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

Postby DeepSOIC » Sat Mar 25, 2017 12:08 pm

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
Posts: 1540
Joined: Tue Jan 03, 2017 10:55 am

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

Postby realthunder » Sat Mar 25, 2017 12:50 pm

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 (latest version 0.11) along 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
Posts: 7600
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

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

Postby DeepSOIC » Sat Mar 25, 2017 12:58 pm

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
Site Admin
Posts: 11845
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

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

Postby yorik » Sat Mar 25, 2017 3:03 pm

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
Posts: 1540
Joined: Tue Jan 03, 2017 10:55 am

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

Postby realthunder » Sat Mar 25, 2017 3:53 pm

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 (latest version 0.11) along 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
Posts: 1540
Joined: Tue Jan 03, 2017 10:55 am

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

Postby realthunder » Sat Mar 25, 2017 4:05 pm

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 (latest version 0.11) along 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