Why an object can only be inside one App::Part?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Veteran
- Posts: 2190
- Joined: Tue Jan 03, 2017 10:55 am
Why an object can only be inside one App::Part?
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?
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?
Re: Why an object can only be inside one App::Part?
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.
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.
- 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?
(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 .
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 .
-
- Veteran
- Posts: 2190
- Joined: Tue Jan 03, 2017 10:55 am
Re: Why an object can only be inside one App::Part?
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.
- 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?
I think I managed to pull ickby to my side, so to say
I'm not quite sure what are you proposing. Please explain in more detail. Do you want Shapebinder to become Instance?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.
-
- Veteran
- Posts: 2190
- Joined: Tue Jan 03, 2017 10:55 am
Re: Why an object can only be inside one App::Part?
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.DeepSOIC wrote:I'm not quite sure what are you proposing. Please explain in more detail. Do you want Shapebinder to become Instance?
- 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?
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?
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?
Re: Why an object can only be inside one App::Part?
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...
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...
-
- Veteran
- Posts: 2190
- Joined: Tue Jan 03, 2017 10:55 am
Re: Why an object can only be inside one App::Part?
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:Selecting "Edge1" of instance is probably not useful, as there is no way to look up where that edge actually is.
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?DeepSOIC wrote:Any thoughts on array support inside instances?
-
- Veteran
- Posts: 2190
- Joined: Tue Jan 03, 2017 10:55 am
Re: Why an object can only be inside one App::Part?
Wow, the "Hire" thing is very similar to my idea. Darn it, someone beats me to ityorik 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...