Bisector line - my first macro

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Stq_Niko
Posts: 24
Joined: Fri Jun 14, 2019 7:07 pm
Location: France

Re: Bisector line - my first macro

Post by Stq_Niko »

wandererfan wrote: Tue Jun 02, 2020 11:56 pm
Stq_Niko wrote: Tue Jun 02, 2020 5:04 pm there is an easy way to modify the placement of an edge ?
No. I missed that when I took out the replacement code. :oops:

Would something like vector = ce.getStartPoint() and ce.setStartPoint(vector) do the job?
Yes, Something like ce.setStartPoint(vector) and ce.setEndPoint(vector) or ce.FirstVertex().Point = vector and ce.LastVertex().Point = vector
The first solution is better I think
It would be great if it can be applied to edges too and not only cometicEdge
User avatar
wandererfan
Veteran
Posts: 6317
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Bisector line - my first macro

Post by wandererfan »

Stq_Niko wrote: Sat Jun 06, 2020 1:50 pm
Start, End, Center and Radius attributes for CosmeticEdge implemented here: git commit 4183594039

Code: Select all

>>> v = App.ActiveDocument.View
>>> ce = v.getCosmeticEdgeBySelection("Edge5")
>>> ce.Start
Vector (-5.0, -5.0, 0.0)
>>> pt = App.Vector(0.0, -5.0, 0.0)
>>> ce.Start = pt
>>> ce.Start
Vector (0.0, 5.0, 0.0)
>>> ce.End
Vector (5.0, 5.0, 0.0)
>>> 
It would be great if it can be applied to edges too and not only cometicEdge
Don't understand this one. Why would you want the drawing to be different from the model?
Stq_Niko
Posts: 24
Joined: Fri Jun 14, 2019 7:07 pm
Location: France

Re: Bisector line - my first macro

Post by Stq_Niko »

Thanks, That's great !

I will try it as soon as I can ...

Don't understand this one. Why would you want the drawing to be different from the model?
I understand what you mean. I was not thinking to make the drawing different from the model, but may be have the possibilty to correct the drawing if something goes wrong (In case of) or adapt the drawing for some specials cases :
Attachments
aretes_fictives_1.PNG
aretes_fictives_1.PNG (103.59 KiB) Viewed 1735 times
aretes_fictives_2.png
aretes_fictives_2.png (10.62 KiB) Viewed 1735 times
Stq_Niko
Posts: 24
Joined: Fri Jun 14, 2019 7:07 pm
Location: France

Re: Bisector line - my first macro

Post by Stq_Niko »

Hello,

I got some free time to post my feedback for Start and End attributes for CosmeticEdge (Center and Radius not tested yet)

I have noticed something weird :

If I change only Start attribut ==> OK
If I change only End attribut ==> OK
If I change Start and End attribut ==> NOK

NB:
Need to add this to draw the modified CosmeticEdge, recompute only is not enough

App.ActiveDocument.ProjItem.touch()
App.ActiveDocument.recompute()

See pictures bellow :
Capture Initial.PNG
Capture Initial.PNG (17.84 KiB) Viewed 1698 times
Capture Start only.PNG
Capture Start only.PNG (25.05 KiB) Viewed 1698 times
Capture End only.PNG
Capture End only.PNG (25.74 KiB) Viewed 1698 times
Capture Start & End.PNG
Capture Start & End.PNG (24.8 KiB) Viewed 1698 times
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.21654 (Git)
Build type: Release
Branch: master
Hash: ddf0cf3136a6c5a459abae4bf1f9c714f6f45c86
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/France (fr_FR)
User avatar
wandererfan
Veteran
Posts: 6317
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Bisector line - my first macro

Post by wandererfan »

Stq_Niko wrote: Fri Jun 19, 2020 2:46 pm If I change only Start attribut ==> OK
If I change only End attribut ==> OK
If I change Start and End attribut ==> NOK
should be fixed by git commit 002e25b561.
Need to add this to draw the modified CosmeticEdge, recompute only is not enough

App.ActiveDocument.ProjItem.touch()
App.ActiveDocument.recompute()
You do need to trigger a recompute yourself (cosmetic items don't mark their owners as touched()), but you don't need to recompute the whole document. App.ActiveDocument.ProjItem.recompute() should be enough (and quicker).
User avatar
wandererfan
Veteran
Posts: 6317
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Bisector line - my first macro

Post by wandererfan »

Stq_Niko wrote: Wed Jun 10, 2020 6:26 pm I understand what you mean. I was not thinking to make the drawing different from the model, but may be have the possibilty to correct the drawing if something goes wrong (In case of) or adapt the drawing for some specials cases :
You can hide the real line with TechDraw_DecorateLine, then add a cosmetic edge as a replacement.
Stq_Niko
Posts: 24
Joined: Fri Jun 14, 2019 7:07 pm
Location: France

Re: Bisector line - my first macro

Post by Stq_Niko »

Thanks for your work

I will use document. App.ActiveDocument.ProjItem.recompute()

wandererfan wrote: Sat Jun 20, 2020 4:50 pm
Stq_Niko wrote: Wed Jun 10, 2020 6:26 pm I understand what you mean. I was not thinking to make the drawing different from the model, but may be have the possibilty to correct the drawing if something goes wrong (In case of) or adapt the drawing for some specials cases :
You can hide the real line with TechDraw_DecorateLine, then add a cosmetic edge as a replacement.
I didn't think to do that way, but it's also a good solution
Stq_Niko
Posts: 24
Joined: Fri Jun 14, 2019 7:07 pm
Location: France

Re: Bisector line - my first macro

Post by Stq_Niko »

Hello,

Hope Everything is fine for you

Well, I got some time to work on my macros ...

I think it still a bug on the Y invertion :

1) CometicEdge creation :
Create cometicEdge.png
Create cometicEdge.png (12.72 KiB) Viewed 1598 times

2) Read the CometicEdge.Start attribut :
Read CometicEdge.Start.png
Read CometicEdge.Start.png (9.78 KiB) Viewed 1598 times

3) Modification of the CosmeticEdge.End Attribut :
CometicEdge modification.png
CometicEdge modification.png (13.65 KiB) Viewed 1598 times

4) Read again the CosmeticEdge.Start :
Read CometicEdge.Start again.png
Read CometicEdge.Start again.png (8.15 KiB) Viewed 1598 times

As we can see the Y axis sign has changed !



Word size of FreeCAD: 64-bit
Version: 0.19.21777 (Git)
Build type: Release
Branch: master
Hash: 478823b90967a9b76796c64f74b8e3a5440150fa
User avatar
wandererfan
Veteran
Posts: 6317
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Bisector line - my first macro

Post by wandererfan »

Stq_Niko wrote: Tue Jun 30, 2020 4:38 pm
Should be fixed by git commit 19d37ec5df.
Stq_Niko
Posts: 24
Joined: Fri Jun 14, 2019 7:07 pm
Location: France

Re: Bisector line - my first macro

Post by Stq_Niko »

wandererfan wrote: Thu Jul 02, 2020 12:26 am
Stq_Niko wrote: Tue Jun 30, 2020 4:38 pm
Should be fixed by git commit 19d37ec5df.
Fine, Thanks a lot !

By the way it comes to me a question ...
How TechDraw manages to render views from the 3D objects ?
So, I think TechDraw use OCC to do the job, and I understand that OCC names view elements (edges, points, etc ...) arbitrarily, and then there is no way to link an element from the view to a 3D object element.
But, in a view where multi 3D objects are rendered, is there a way to know from which 3D object comes from edges, points, surface ?
Maybe not at the end of the process when the view is drawed, but before or during the rendering process ...
The idea behind my question is : can we change the way to render each objet (eg. change the line style)
For example, it would be usefull for cut view of part with screw : in a drawing we cut parts but not screws which are showed uncut
Or for a thread is an other example :

Capture filetage 3D.PNG
Capture filetage 3D.PNG (12.62 KiB) Viewed 1542 times
Capture filetage top.PNG
Capture filetage top.PNG (15.21 KiB) Viewed 1542 times
Capture filetage coupe.PNG
Capture filetage coupe.PNG (13.38 KiB) Viewed 1542 times
Post Reply