Constraints extended naming

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!
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Constraints extended naming

Post by easyw-fc »

abdullah wrote: Fri May 25, 2018 12:22 pm ...
Just a bit off topic... but related to Sketcher new features...
would it be possible to add the option to move/shift the Sketch by a python command?
I found the option to Copy a Sketch, but not to Move it...
Should I make a feature request for this?
chrisb
Veteran
Posts: 54280
Joined: Tue Mar 17, 2015 9:14 am

Re: Constraints extended naming

Post by chrisb »

I don't really mind starting at 0, even for the normal user. And of course in all other places too. Sooner or later an interested user might start doing small things in python and it is much more natural if the numbering is the same.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Constraints extended naming

Post by bejant »

abdullah wrote: Fri May 25, 2018 12:22 pm This also happens when in expressions you use .Constraints[0], the indexing for the array is zero-based, like in c++, but this is Constraint1 in the widget.

I do believe this is misleading.

If I create a default Cube primitive, the Status Bar displays the Edges as 1 through 12 and the Faces as 1 through 6.
But internally do the Edge and Face numberings start at zero?
Internally (before it is displayed in the widgets) what (if anything) in FreeCAD begins with numbering starting at 1?

Assuming it doesn't break other things (macros and workbenches, as you mentioned) I think the numberings should all start at the same value, if that is possible and reasonable to do.

I think that has to be resolved before deciding on how to make it available (meaning an easily changed setting vs. not so obvious) to the regular user (Advanced Solver Controls and BOPCheck come to mind).

Personally, I favor the ability to display Geold / Posld info as in that image in the first post.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Constraints extended naming

Post by looo »

abdullah wrote:Do you see a meaningful impact from changing in the Sketcher, the constraint names from being one-based indices, e.g. Constraint1, Constraint2, to Constraint0, Constraint1; and the same for elements (Edge0, Edge1)? Would you favour such change or not?
1-based or 0-based, I guess there is no convention for freecad. As far as I know occt is 1-based (eg setting poles of bspline) and python is 0-based. Maybe the convention should be: everything exposed to python should be 0-based.But then some functions need to be updated and then some stuff will break and then some people will wine. So better create the convention that everything new and exposed to python is 0-based and all existing 1-based stuff is historically unconventional.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Constraints extended naming

Post by abdullah »

easyw-fc wrote: Fri May 25, 2018 1:46 pm
abdullah wrote: Fri May 25, 2018 12:22 pm ...
Just a bit off topic... but related to Sketcher new features...
would it be possible to add the option to move/shift the Sketch by a python command?
I found the option to Copy a Sketch, but not to Move it...
Should I make a feature request for this?
Do you mean this?
Move_Sketcher.gif
Move_Sketcher.gif (227.94 KiB) Viewed 1191 times
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Constraints extended naming

Post by easyw-fc »

abdullah wrote: Mon May 28, 2018 3:52 pm Do you mean this?
yes! :D
Thx a lot as always!
Maurice
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Constraints extended naming

Post by abdullah »

easyw-fc wrote: Mon May 28, 2018 4:06 pm
abdullah wrote: Mon May 28, 2018 3:52 pm Do you mean this?
yes! :D
Thx a lot as always!
Maurice
There is still some tweaking to do with autoconstraints, but you get a new Python command:
App.ActiveDocument.Sketch.addMove([0,1,2,3],App.Vector(112.508167,-26.925030,0))

The first is a list of GeoIds to move, the second is a vector defining the displacement.
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Constraints extended naming

Post by easyw-fc »

abdullah wrote: Mon May 28, 2018 5:22 pm but you get a new Python command:
App.ActiveDocument.Sketch.addMove([0,1,2,3],App.Vector(112.508167,-26.925030,0))

The first is a list of GeoIds to move, the second is a vector defining the displacement.
would it be possible to have a default option to move all Geometry i.e. giving the first parameter empty?
([],,App.Vector(112.508167,-26.925030,0))
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Constraints extended naming

Post by abdullah »

easyw-fc wrote: Mon May 28, 2018 9:12 pm would it be possible to have a default option to move all Geometry i.e. giving the first parameter empty?
([],,App.Vector(112.508167,-26.925030,0))
Sure. I have implemented this. Because internally move, copy, clone and rectangular array use the same c++ function, all of them inherit this behaviour.
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Constraints extended naming

Post by easyw-fc »

abdullah wrote: Mon May 28, 2018 9:33 pm Sure. I have implemented this. Because internally move, copy, clone and rectangular array use the same c++ function, all of them inherit this behaviour.
:D 8-) :geek:
Post Reply