Constraints extended naming

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
easyw-fc
Posts: 2589
Joined: Thu Jul 09, 2015 9:34 am

Re: Constraints extended naming

Postby easyw-fc » 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?
chrisb
Posts: 16957
Joined: Tue Mar 17, 2015 9:14 am

Re: Constraints extended naming

Postby chrisb » Fri May 25, 2018 2:33 pm

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.
User avatar
bejant
Posts: 5731
Joined: Thu Jul 11, 2013 3:06 pm

Re: Constraints extended naming

Postby bejant » Fri May 25, 2018 4:52 pm

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.
looo
Posts: 2666
Joined: Mon Nov 11, 2013 5:29 pm

Re: Constraints extended naming

Postby looo » Fri May 25, 2018 9:19 pm

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
Posts: 3174
Joined: Sun May 04, 2014 3:16 pm

Re: Constraints extended naming

Postby abdullah » Mon May 28, 2018 3:52 pm

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 254 times
User avatar
easyw-fc
Posts: 2589
Joined: Thu Jul 09, 2015 9:34 am

Re: Constraints extended naming

Postby easyw-fc » 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
abdullah
Posts: 3174
Joined: Sun May 04, 2014 3:16 pm

Re: Constraints extended naming

Postby abdullah » Mon May 28, 2018 5:22 pm

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
Posts: 2589
Joined: Thu Jul 09, 2015 9:34 am

Re: Constraints extended naming

Postby easyw-fc » Mon May 28, 2018 9:12 pm

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
Posts: 3174
Joined: Sun May 04, 2014 3:16 pm

Re: Constraints extended naming

Postby abdullah » Mon May 28, 2018 9:33 pm

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
Posts: 2589
Joined: Thu Jul 09, 2015 9:34 am

Re: Constraints extended naming

Postby easyw-fc » Mon May 28, 2018 9:51 pm

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: