Feature request : round corner rectangle

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
leoheck
Posts: 375
Joined: Tue Mar 13, 2018 5:56 pm

Re: Feature request : round corner rectangle

Postby leoheck » Sat Apr 18, 2020 10:12 pm

Nice Macro. I updated the interface a little bit to be more consistent with the Freecad UI.
Screenshot-20200418191036-320x335.png
Screenshot-20200418191036-320x335.png (17.17 KiB) Viewed 730 times
I changed it to use the constraint by default as chrisb said, which I think is a valid decision.
I also fixed the constrained Circle that had a typo in the parameter.

I was not able to change the constraints to use the diagonal symmetry yet. I didn't have much time to understand the methods yet.

It is attached here if one of you knows how to improve the constraints. I would be glad to have the best constraints applied.
CenteredFiguresInSketcher.FCMacro
(17.22 KiB) Downloaded 20 times
edi
Posts: 51
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature request : round corner rectangle

Postby edi » Sat Jul 18, 2020 8:43 am

Attached you will find a revised version of the script, considering all wishes remarked till now.
There is a new interface applied, shown in the combo view.
CenteredFiguresInSketcher.FCMacro
(13.07 KiB) Downloaded 13 times
Please give me further desires and comments.
User avatar
easyw-fc
Posts: 2857
Joined: Thu Jul 09, 2015 9:34 am

Re: Feature request : round corner rectangle

Postby easyw-fc » Sat Jul 18, 2020 9:01 am

edi wrote:
Sat Jul 18, 2020 8:43 am
Attached you will find a revised version of the script, considering all wishes remarked till now.
There is a new interface applied, shown in the combo view.
CenteredFiguresInSketcher.FCMacro
Please give me further desires and comments.
I just discovered this nice macro! :D
I think it should be included inside the FC main code or at least available in the Addons Macro list.
chrisb
Posts: 25836
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature request : round corner rectangle

Postby chrisb » Sun Jul 19, 2020 6:27 am

Nice macro, so please see my comment as envcouragement and not as negative criticism.

I wonder if it is possible to center the figures around an arbitrary point, not just the origin. The workflow would be:
- if a point is selected, then the figure uses this point as center
- if nothing is selected, the origin is used
- if something else is selected raise an error

Furthermore I found that switching between models is not possible without restarting the model. I did the following:
- open two files with sketches in them
- open sketch in first model
- run the macro; it installs a third tab Centered Figures besides Model and Tasks
- create a figure with the macro; it will be correctly created in the sketch
- switch to the Tasks tab and close the sketch.

- Switch to the other model
- open the sketch in that model
- create a figure; this seems natural, as the additional tab still exists
- it seems as if nothing has happened; in fact another figure is added to the existing sketch in the first model.
chrisb
Posts: 25836
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature request : round corner rectangle

Postby chrisb » Sun Jul 19, 2020 6:39 am

I can very well imagine to use these macros to extend an existing sketch. However, this fails, because the constraints are applied to the wrong elements:
- create a sketch with a circle
- use the macro to add a centered rectangle
Snip macro screenshot-a329be.png
Snip macro screenshot-a329be.png (5.24 KiB) Viewed 481 times
Result:
- the circle gets a forbidden horizontal constraint
- the constraints of the rectangle are out of whack

If I create manually a rectangle and add then the macro the dimensions are added to the wrong rectangle. If I move the first rectangle it snaps to the center.
Snip macro screenshot-cd09f0.png
Snip macro screenshot-cd09f0.png (4.71 KiB) Viewed 481 times
chrisb
Posts: 25836
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature request : round corner rectangle

Postby chrisb » Sun Jul 19, 2020 6:44 am

And a final remark: It is recommended to use the HorizontalDistance constraint on horizontal lines and VerticalDistance on vertical lines instead of Length constraints.
It would be nice to have this at least as the default.
edi
Posts: 51
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature request : round corner rectangle

Postby edi » Fri Jul 24, 2020 3:54 pm

@chrisb: I am editing the script trying to follow your suggestion
I wonder if it is possible to center the figures around an arbitrary point, not just the origin. The workflow would be:
- if a point is selected, then the figure uses this point as center
In
I discovered a way to get the selected point in the sketch.
by chrisb » Wed Apr 11, 2018 6:55 am
use

Code: Select all

FreeCADGui.Selection.getSelectionEx()[0].SubObjects[0]
to get the vertex instead of his name.
I have an open sketch with only one point selected. When I try in the python console the following error message occures

Code: Select all

>>> Gui.Selection.getSelectionEx()[0].SubElementNames[0]
'Vertex11'
>>> Gui.Selection.getSelectionEx()[0].SubObjects[0]
Traceback (most recent call last):
  File "<input>", line 1, in <module>
IndexError: tuple index out of range
OS: Ubuntu 18.04.4 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.4.
Build type: Release
Python version: 3.6.8
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Austria (de_AT)
chrisb
Posts: 25836
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature request : round corner rectangle

Postby chrisb » Sun Jul 26, 2020 12:09 am

edi wrote:
Fri Jul 24, 2020 3:54 pm
I have an open sketch with only one point selected.
Sorry for the late reply.
I have tested in an open sketch
- select the origin
- select an end point of a line
- select a geometric element point
- select the center of a circle
- select the endpoint of an arc

no errors here. You may try with a current 0.19.

OS: macOS High Sierra (10.13)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.21938 (Git)
Build type: Release
Branch: master
Hash: 5666598a6be219830a992610243fe23144a61453
Python version: 3.8.2
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: C/Default (C)
edi
Posts: 51
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature request : round corner rectangle

Postby edi » Tue Jul 28, 2020 1:29 pm

Furthermore I found that switching between models is not possible without restarting the model. I did the following:
- open two files with sketches in them
- open sketch in first model
- run the macro; it installs a third tab Centered Figures besides Model and Tasks
- create a figure with the macro; it will be correctly created in the sketch
- switch to the Tasks tab and close the sketch.

- Switch to the other model
- open the sketch in that model
- create a figure; this seems natural, as the additional tab still exists
- it seems as if nothing has happened; in fact another figure is added to the existing sketch in the first model.
I think that bug is removed. Please test new version attached. While the macro is active you can switch between documents, and in a document between sketches.

My concept is to support loft and pipe commands: Before starting the script, the user should have (using another script) created many empty sketches perpendicular to a spine curve. Now my script is started. You switch between the empty sketches generating related sections in every sketch.

A desirable approach would be, to close the macro when swapping between documents. But I found no solution as yet.

Next I will attempt to provide the other suggestions.
Attachments
CenteredFiguresInSketcher.FCMacro
(13.78 KiB) Downloaded 7 times
chrisb
Posts: 25836
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature request : round corner rectangle

Postby chrisb » Thu Jul 30, 2020 10:36 pm

Thanks. The test may have to wait until the weekend.