Element widget for Sketcher WB

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Element widget for Sketcher WB

Post by jmaustpc »

Hi Abdullah

Something is wrong with the naming for the external geometry elements, they are numbered with a hyphen where as other items are not.

this is just a simple file I used for testing.
elementeexternalgeometrytesting.fcstd
(35.44 KiB) Downloaded 74 times
externaslgeometryelementswidgettesting.jpg
externaslgeometryelementswidgettesting.jpg (22.22 KiB) Viewed 2403 times
if you look at the point external geometry in sketch001 and the edges external geometry in sketch002, you will see what I mean.

This is sketch001, you can see that the first point is point(Edge6) which is a normal point I added into the sketch where as the next two points are external geometry points, Point (Edge-3) and point (Edge-4)
externaslgeometryelementswidgettesting1.jpg
externaslgeometryelementswidgettesting1.jpg (21.69 KiB) Viewed 2403 times

This below is sketch002, the first Line is the ordinary line set to construction mode, where as the next two are external geometry.
externaslgeometryelementswidgettesting2.jpg
externaslgeometryelementswidgettesting2.jpg (13.32 KiB) Viewed 2403 times

Another little thing, in all your branches and in master, I noticed that the extended naming for a point says "edge", is it supposed to?

Jim
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Element widget for Sketcher WB

Post by abdullah »

jmaustpc wrote:Something is wrong with the naming for the external geometry elements, they are numbered with a hyphen where as other items are not.
jmaustpc wrote:Another little thing, in all your branches and in master, I noticed that the extended naming for a point says "edge", is it supposed to?
Extended naming has to do with how a python user could interface with the element. I know nothing of Python and I have never used the python console in FreeCAD. An external geometry is stored internally using negative numbers, so that is the reason for the "hyphen".

Using C++ if I tell selected "Edge-3", it just does work. I think I can also tell select "ExternalEdge3",

However, because I do not know if it works or not from Python. I made the following enquiry some posts ago in this thread:
abdullah wrote:Specially, anyone using python with FreeCAD, this "Edge-3" is what you would expect as extended name, or more "ExternalEdge3", or does not matter??
This I think should be answered by someone that does use python to treat geometry... :? Anywant of you power users out there?


BTW: Edge-1 and -2 are the x and y axes of the sketch..., that is why it starts in -3
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Element widget for Sketcher WB

Post by jmaustpc »

Hi Abdullah

abdullah wrote:Extended naming has to do with how a python user could interface with the element. I know nothing of Python and I have never used the python console in FreeCAD. An external geometry is stored internally using negative numbers, so that is the reason for the "hyphen".

Using C++ if I tell selected "Edge-3", it just does work. I think I can also tell select "ExternalEdge3",
OK, well then all is well! :)

One question does all of the above apply to the points as well? I mean should the extended naming call then an "edge"?

If the above is correct then I suggest you create a pull request for this.

Jim
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Element widget for Sketcher WB

Post by abdullah »

Hi Jim!

I have just realised that when you select one object, in the status bar you can see the python name. So, Edge-3 is actually ExternalEdge1 (abs(index)-2). I have adapted the code to show this.
jmaustpc wrote:One question does all of the above apply to the points as well? I mean should the extended naming call then an "edge"?
The extended naming is intended for the edge, consistent with non-external elements. The list does not get updated when you change element, it is saying you are selecting the starting point of ExternalEdge1.

Pull requested in: viewtopic.php?f=17&t=7921
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Element widget for Sketcher WB

Post by jmaustpc »

abdullah wrote:
jmaustpc wrote:One question does all of the above apply to the points as well? I mean should the extended naming call then an "edge"?
The extended naming is intended for the edge, consistent with non-external elements. The list does not get updated when you change element, it is saying you are selecting the starting point of ExternalEdge1.

Pull requested in: viewtopic.php?f=17&t=7921
Hi Abdullah :)
Just checking, do you know that I am talking about the "point" element in sketcher? Not a starting or ending point on a line or anything else, just the plain "point" object? Hence it has no edge associated with it. I am not talking about the names changing when the selection type is changed in the drop down list. I am talking about the name generated on creation, on first putting a sketcher "point" object into a sketch. :)

Jim
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Element widget for Sketcher WB

Post by abdullah »

jmaustpc wrote:Just checking, do you know that I am talking about the "point" element in sketcher?
Ah! No I was not understanding you :) . However, that is quite of a funny story: the points are also edges (at least for the c++ implementation). I have no clue if a python user can actually use the edge or not. I would really really like to know this from someone that usually uses Python in freeCAD.

Nevertheless, that is material for another pull request. I mean, the current pull request is for supporting external geometry, so it can go ahead.

Then, if someone knowledgable in python would be so kind to tell (or test), if the edge is usable in Python, then we can prepare another feature enhancement with this information. You can even make another ticket and assign it to me ;)
User avatar
AndroYD
Posts: 11
Joined: Fri Nov 25, 2022 7:57 am

Re: Element widget for Sketcher WB

Post by AndroYD »

Sorry for resurrecting an old thread, but it's where the "Auto-switch to Edge" option was born (in the "Elements" list).
ElementsGreyedOut.png
ElementsGreyedOut.png (40.65 KiB) Viewed 513 times
Many online solutions to FreeCAD were from before this option existed, the fact that by default "Type: Edge" option is now always greyed-out unless you untick the "Auto-switch to Edge" checkbox (you have to actually look up of it) doesn't help at all.
NeedToScrollDownToFind.png
NeedToScrollDownToFind.png (37.06 KiB) Viewed 513 times
This can cause a lot of misunderstandings (being undocumented and all) since every users' solutions and official documentation doesn't mention it, I was baited in searching all kind of wrong solutions this whole time where I would end up "screwing a lightbulb by rotating the house" and I've been using FreeCAD wrongly for three months now because I never saw it functioning once and never knew any better.

To avoid any more of these incidents in the future, I suggest that instead of greying-out/disabling the drop-down menu entirely, to still allow looking at the different options (so documentation/solutions make sense), but selecting anything other than "Edge" will causes the "Auto-switch to Edge" checkbox to untick automatically (optionally a pop-up warning to remind them of that?). What do you think?
chrisb
Veteran
Posts: 53785
Joined: Tue Mar 17, 2015 9:14 am

Re: Element widget for Sketcher WB

Post by chrisb »

AndroYD wrote: Fri Dec 09, 2022 9:56 am What do you think?
I think you should recheck in current 0.21, where the elements list has significantly changed.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply