App::Link: the big merge

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
wmayer
Site Admin
Posts: 14988
Joined: Thu Feb 19, 2009 10:32 am

Re: App::Link: the big merge

Postby wmayer » Wed Aug 28, 2019 8:16 am

I am afraid that's not possible. It is exactly because the label can be changed to anything, e.g. with space, it must be quoted, with the double bracket. It's just a bit unfortunate that the quoting style is not so natural.
In Py2 the name of an identifier is quite restricted like in most other programming languages, too. This means it is only allowed to contain alphanumeric characters, must not start with a digit, no space, ....
However, in Py3 an identifier is allowed to actually contain any character -- even a dot or any kind of unicode. Of course when using such special characters you cannot use the identifier directly but instead you must use setattr/getattr.

Example:

Code: Select all

import __main__
setattr(__main__,"an identifier with a .", "test")
dir()
So, if we apply this idea to expressions we could add a built-in function to access an object by its label.
User avatar
Zolko
Posts: 445
Joined: Mon Dec 17, 2018 10:02 am

Re: App::Link: the big merge

Postby Zolko » Wed Aug 28, 2019 8:46 am

kisolre wrote:
Sun Aug 25, 2019 10:58 am
Can a linked object be used as PD basefeature?
Please NO, this is a VERY bad idea.

user1234 wrote:
Tue Aug 13, 2019 7:08 pm
Suggestion one: I know from other CAD software, that linked objects like you make, have an extra group for linked objects (as far i remember the term is publication).
THIS is the good behaviour: references between external objects should be actively decided by the designer(s), in other words a part should ACTIVELY PUBLISH which of its features can be externally used, all others should NOT be externally referencable (even though still visible). References between parts are like APIs, they must be maintained and stable, which is possible only if the designer commits himself to maintain them. If a random feature of a part is used externally, chances are that it will break at the subsequent modification of the part.
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — simple tutorial here
chrisb
Posts: 19484
Joined: Tue Mar 17, 2015 9:14 am

Re: App::Link: the big merge

Postby chrisb » Wed Aug 28, 2019 9:13 am

Zolko wrote:
Wed Aug 28, 2019 8:46 am
kisolre wrote:
Sun Aug 25, 2019 10:58 am
Can a linked object be used as PD basefeature?
Please NO, this is a VERY bad idea.
Can you elaborate? I don't see a big difference to the current BaseFeature concept, where a link is created as well. Or do you think the current concept is a bad idea as well?
User avatar
Zolko
Posts: 445
Joined: Mon Dec 17, 2018 10:02 am

Re: App::Link: the big merge

Postby Zolko » Wed Aug 28, 2019 9:22 am

chrisb wrote:
Wed Aug 28, 2019 9:13 am
Zolko wrote:
Wed Aug 28, 2019 8:46 am
kisolre wrote:
Sun Aug 25, 2019 10:58 am
Can a linked object be used as PD basefeature?
Please NO, this is a VERY bad idea.
Can you elaborate? I don't see a big difference to the current BaseFeature concept, where a link is created as well.
does "the current BaseFeature concep" apply across linked documents (as per App::Link), or only inside one single document ?
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — simple tutorial here
realthunder
Posts: 1229
Joined: Tue Jan 03, 2017 10:55 am

Re: App::Link: the big merge

Postby realthunder » Wed Aug 28, 2019 9:31 am

wmayer wrote:
Wed Aug 28, 2019 8:16 am
So, if we apply this idea to expressions we could add a built-in function to access an object by its label.
But a built-in function requires its argument to be quoted as well. I don't see any escape from quoting for a string that can contain anything, unless we allow something like escape character '\', which is more obscure IMO.
Try Assembly3 (latest version 0.10.2) 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
chrisb
Posts: 19484
Joined: Tue Mar 17, 2015 9:14 am

Re: App::Link: the big merge

Postby chrisb » Wed Aug 28, 2019 9:35 am

Zolko wrote:
Wed Aug 28, 2019 9:22 am
does "the current BaseFeature concep" apply across linked documents (as per App::Link), or only inside one single document ?
There is no official assembly workbench yet, thus the current concept applies mainly inside one document. In a2+ it is possible to use an object from an external file as BaseFeature.

I don't see a big difference in internal vs. external. It is just a matter of storage location. An internal object can well be placed in a separate PartContainer and be reused in several places, just like one from an external file. The concept you described above seems to be heavily inspired by object oriented programming languages. I am not sure - which doesn't mean I reject it - if this concept holds for 3D modeled objects too.
wmayer
Site Admin
Posts: 14988
Joined: Thu Feb 19, 2009 10:32 am

Re: App::Link: the big merge

Postby wmayer » Sun Sep 01, 2019 4:34 pm

chrisb
Posts: 19484
Joined: Tue Mar 17, 2015 9:14 am

Re: App::Link: the big merge

Postby chrisb » Mon Sep 02, 2019 9:45 am

The latest update brought improvements in Expression auto complete: now the labels of objects can be used and a completion list is shown. However, this ends after the constraints. Especially the named constraints are not offered.

It used to be like that: Already when typing something like SketchXXX.Con the extensions included all named constraints:
Attachments
Bildschirmfoto 2019-09-02 um 11.42.41.png
Bildschirmfoto 2019-09-02 um 11.42.41.png (17.2 KiB) Viewed 649 times
realthunder
Posts: 1229
Joined: Tue Jan 03, 2017 10:55 am

Re: App::Link: the big merge

Postby realthunder » Mon Sep 02, 2019 10:58 am

chrisb wrote:
Mon Sep 02, 2019 9:45 am
The latest update brought improvements in Expression auto complete: now the labels of objects can be used and a completion list is shown. However, this ends after the constraints. Especially the named constraints are not offered.

It used to be like that: Already when typing something like SketchXXX.Con the extensions included all named constraints:
Yes, I am aware of this. Previously expression can only refer to some very limited path defined by a property, so it show them all. But now expression can refer to any python attribute, it is not practical to list them all. I'll think of a way to get further completion, like when typing in the Python console.
Try Assembly3 (latest version 0.10.2) 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
Zolko
Posts: 445
Joined: Mon Dec 17, 2018 10:02 am

Re: App::Link: the big merge

Postby Zolko » Mon Sep 02, 2019 11:11 am

When I insert a link (App::Link), it has a Placement and a Link Placement property, which seem identical: when I modify one, the other is changed. What is the rationale behind it ? Testing with the lates AppImage 18009 on Linux:

OS: Ubuntu 18.04.2 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18009 (Git) AppImage
Build type: Release
Branch: master
Hash: 0641ca0d1e020d18f23d2adb49959195266f04f7
Python version: 3.7.3
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — simple tutorial here