Macro: Version 3: helper tools to improve TechDraw documents
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Macro: Version 3: helper tools to improve TechDraw documents
Hi ngocminhdao88,
see in the right picture the solution I could find. It's not perfect. Workflow:
- create a temporary centerline using the "Draw one centerline" tool of TechDrawTools macro (see left picture)
- create intersection vertexes with arcs using "Create vertex(es) at intersection" tool of TechDrawTools macro
- delete the temporary centerline
- create the 3 centerlines between vertexes using TechDraw's "Add cosmetic line" icon
A problem is, that TechDraw's "Add a centerline between two lines" has an issue if the lines are slanted.
I will try to create a helper tool: "Extend cosmetic line", which will enable to plot centerlines having a protrusion.
see in the right picture the solution I could find. It's not perfect. Workflow:
- create a temporary centerline using the "Draw one centerline" tool of TechDrawTools macro (see left picture)
- create intersection vertexes with arcs using "Create vertex(es) at intersection" tool of TechDrawTools macro
- delete the temporary centerline
- create the 3 centerlines between vertexes using TechDraw's "Add cosmetic line" icon
A problem is, that TechDraw's "Add a centerline between two lines" has an issue if the lines are slanted.
I will try to create a helper tool: "Extend cosmetic line", which will enable to plot centerlines having a protrusion.
-
- Posts: 73
- Joined: Wed Nov 11, 2020 10:43 am
Re: Macro: Version 3: helper tools to improve TechDraw documents
Hi edi,
thank you for the tips. I was able to created a view showed below.
I don't get what you meant by
A tool to extent cosmetic lines interactively (to the left, to the right by some amount) could be useful in some use case.
thank you for the tips. I was able to created a view showed below.
I don't get what you meant by
I was able to create the center line between two slanted lines using the TechDraw's function fine.A problem is, that TechDraw's "Add a centerline between two lines" has an issue if the lines are slanted.
A tool to extent cosmetic lines interactively (to the left, to the right by some amount) could be useful in some use case.
Re: Macro: Version 3: helper tools to improve TechDraw documents
how did you do it ?ngocminhdao88 wrote: ↑Tue Mar 23, 2021 7:48 pm I was able to create the center line between two slanted lines using the TechDraw's function fine.
If I selcet the two parallel lines and use the "Adds a Centerline between 2 Lines" icon, no line is created. I get the message: "Endpoints are equal".
Maybe your two lines by a fortunate coincidence have the same direction (e.g. startpoint left, endpoint right). Try to create the slot using the polyline command in the sketcher (using the M key). If the two lines have opposite directions (in memory) the issue will occur.
If you publish the file I can check this.
PS: try attached file, having two slanted slots.
- Left slot: centerline can be created, because the two parallel lines have the same direction.
- Right slot: issue occures, because the two parallel lines have different directions.
- TechDrawTools.Macro: both slots are OK.
-
- Posts: 73
- Joined: Wed Nov 11, 2020 10:43 am
Re: Macro: Version 3: helper tools to improve TechDraw documents
Hi edi,
you were faster than me to upload sample file.
you were faster than me to upload sample file.
Indeed, it doesn't work, when the draw direction of both lines are not the same. Since i am right handed, i always draw from left to right .If the two lines have opposite directions (in memory) the issue will occur.
Re: Macro: Version 3: helper tools to improve TechDraw documents
Hi, had a quick look at your macro.
For some reasons, this is not advised to use a QMainWindow with StayOnTopHint for this kind of purposes.
The preferred way is to use a QDialog with Tool flag.
I started a tutorial to demonstrate. Unfortunately only the code is available now, wiki page isn't started yet. However it can probably explain by itself : https://github.com/0penBrain/FreeCAD-ma ... og.FCMacro
Another good way is to use a QDockWidget. It can be very practical for this usage as user can dock it (eg. on the right of the screen) or keep it floating.
Feel free to ask if more information needed.
Re: Macro: Version 3: helper tools to improve TechDraw documents
Hi openBrain,
thank you very much for your post.
The goal of TechDrawTools.FCMacro was, to create a container which stays active - whatever is done in FC - until it is closed by the user. chrisb gave me a hint to Macro_FCCamera.FCMacro published by mario52, which I used as guide. I adopted your method which is using PySide2. It is working. Compared with the old method (using PySide) the difference is, that the window disappeares if the user swaps from FreeCAD to another program, and is back if the user returns to FreeCAD again. In PySide2 many methods changed from QtGui to QtWidgets.
To your macro: I am far away from appreciating it in detail, but tested the selection observer using a TechDraw document.
the Following behavior occured:
- If selecting a TechDraw view or section view: The view (as a string) is returned in obj, that is OK
- If selecting a TechDraw dimension: The dimension (as a string) is returned in obj, that is OK
- If selecting a TechDraw geometric element (vertex or line) then addselection is called twice:
at "mouse DOWN" the selected view is returned in obj, an empty string in sub is returned
at "mouse UP" the selected view is returned in obj and the selected vertex or line is returned in sub
pnt is allways returned as (0.0,0.0,0.0)
I guess it is a problem of defining the type of the event in addEventCallback. Is it possible to obtain the mouse status (UP, DOWN, LEFT, RIGHT) ?
thank you very much for your post.
The goal of TechDrawTools.FCMacro was, to create a container which stays active - whatever is done in FC - until it is closed by the user. chrisb gave me a hint to Macro_FCCamera.FCMacro published by mario52, which I used as guide. I adopted your method which is using PySide2. It is working. Compared with the old method (using PySide) the difference is, that the window disappeares if the user swaps from FreeCAD to another program, and is back if the user returns to FreeCAD again. In PySide2 many methods changed from QtGui to QtWidgets.
To your macro: I am far away from appreciating it in detail, but tested the selection observer using a TechDraw document.
the Following behavior occured:
- If selecting a TechDraw view or section view: The view (as a string) is returned in obj, that is OK
- If selecting a TechDraw dimension: The dimension (as a string) is returned in obj, that is OK
- If selecting a TechDraw geometric element (vertex or line) then addselection is called twice:
at "mouse DOWN" the selected view is returned in obj, an empty string in sub is returned
at "mouse UP" the selected view is returned in obj and the selected vertex or line is returned in sub
pnt is allways returned as (0.0,0.0,0.0)
I guess it is a problem of defining the type of the event in addEventCallback. Is it possible to obtain the mouse status (UP, DOWN, LEFT, RIGHT) ?
Re: Macro: Version 3: helper tools to improve TechDraw documents
Unfortunately this (wrong) usage of QMainWindow+StayOnTopHint is present a lot in FreeCAD wiki and probably had spread itself in the past. That's why I started the tutorial (WIP).
You may actually have kept PySide. The important thing is to use QDialog+Tool.I adopted your method which is using PySide2. It is working. In PySide2 many methods changed from QtGui to QtWidgets.
That's it. Which is far better (IMO) particularly if you have only one screen. I don't want to go doing some web browsing and get the TechDrawTools window over my browser.Compared with the old method (using PySide) the difference is, that the window disappeares if the user swaps from FreeCAD to another program, and is back if the user returns to FreeCAD again.
Also there are other differences you may not have seen :
* With new method, you have only one FC window in the OS task bar. With old QMainWindow, you had 2 which is a bit weird
* With new method you keep only one Qt event loop. QMainWindow creates a second independent event loop, which may lead to issues if you close FC main window while TechDrawTools dialog is open. Now it's clean.
Not sure this is a good idea. There is some specific things with selection in TechDraw and maybe SelectionObserver isn't really friend with them.To your macro: I am far away from appreciating it in detail, but tested the selection observer using a TechDraw document.
My guess is that you maybe found a bug in TechDraw.- If selecting a TechDraw geometric element (vertex or line) then addselection is called twice:
at "mouse DOWN" the selected view is returned in obj, an empty string in sub is returned
at "mouse UP" the selected view is returned in obj and the selected vertex or line is returned in sub
pnt is allways returned as (0.0,0.0,0.0)
I guess it is a problem of defining the type of the event in addEventCallback.
No it isn't. The selection observer is just propagating the 'addSelection' to a custom class. It ignores the way/reason 'addSelection' has been originally called.Is it possible to obtain the mouse status (UP, DOWN, LEFT, RIGHT) ?
Re: Macro: Version 3: helper tools to improve TechDraw documents
Hi Edi, cool work!
I contributed a lot to Techdraw the last time and one of the issues I could not yet solve is that Techdraw does not recognize threaded holes. With FC 0.20 we have now a completely reworked hole tool to make threaded holes. The task is now to make Techdraw aware of these parameters. Despite I am the author of the reworked hole tool, I have no clue on how to teach Techdraw to recognize the threads .
Could you please have a look, if you find an approach to get this to work?
I contributed a lot to Techdraw the last time and one of the issues I could not yet solve is that Techdraw does not recognize threaded holes. With FC 0.20 we have now a completely reworked hole tool to make threaded holes. The task is now to make Techdraw aware of these parameters. Despite I am the author of the reworked hole tool, I have no clue on how to teach Techdraw to recognize the threads .
Could you please have a look, if you find an approach to get this to work?
Re: Macro: Version 3: helper tools to improve TechDraw documents
Hallo edi,
thanks for this great tool. But one question: how can I undo a selection made? I have to close the document without saving and reopen it again. Very awkward. Or did I not notice a button due to my poor English skills? Thank you CM
thanks for this great tool. But one question: how can I undo a selection made? I have to close the document without saving and reopen it again. Very awkward. Or did I not notice a button due to my poor English skills? Thank you CM
Re: Macro: Version 3: helper tools to improve TechDraw documents
Wow, this looks awesome! I'm going to check it out
Regards / Viele Grüße
Max
Max