Feature Request #7257 - When using Draft to Mirror a Part can keep the same color

A forum dedicated to the Draft, Arch and BIM workbenches development.
User avatar
xsuper9988
Posts: 210
Joined: Sat Oct 24, 2020 4:20 am

Feature Request #7257 - When using Draft to Mirror a Part can keep the same color

Post by xsuper9988 »

When I use assembly objects it is often necessary to mirror
But after mirroring, the color of each object will become white
And the color cannot be changed
Can anyone help with this please?
Thank you very much

PS: Reference topic
https://forum.freecadweb.org/viewtopic.php?f=3&t=69860

My Ver.

Code: Select all

OS: Windows 10 (10.0)
Word size of FreeCAD: 64-bit
Version: 0.21.29283 (Git)
Build type: Release
Branch: master
Hash: 15e3e86c5a683f3b2e5c7b95d4b26cd719ab367a
Python 3.8.13, Qt 5.12.9, Coin 4.0.0, Vtk 9.1.0, OCC 7.5.3
Locale: Chinese/Taiwan (zh_TW)
Installed mods: 
  * A2plus 0.4.56a
  * Assembly3 0.11.3
  * Assembly4 0.11.12
  * Curves 0.4.4
  * DynamicData 2.46.0
  * ExplodedAssembly
  * fasteners 0.3.43
  * lattice2 1.0.0
  * parts_library
  * pcb
  * sheetmetal 0.2.49
Attachments
DrafMirrorColor.FCStd
(20.86 KiB) Downloaded 6 times
DrafMirrorColor.png
DrafMirrorColor.png (86.25 KiB) Viewed 719 times
Last edited by Kunda1 on Tue Jul 26, 2022 4:49 pm, edited 3 times in total.
Reason: Added GH ticket number to thread title
User avatar
yorik
Founder
Posts: 12866
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Request Update Feature "Draft Mirror Keeps the Same Color"

Post by yorik »

The Draft mirror tool uses the Part mirror tool internally, which apparently doesn't map colors.
An easy fix we could do directly in Draft, is, after the object has been mirrored, copy over the colors from the original object to the mirrored object. But I am not sure the faces order is kept by the mirroring operation.. If faces order gets shuffled, face colors won't be correctly mapped.

Could you try something like this, see if we get correct results? That would help us to see if the above method would work. In the python console, enter this:

Code: Select all

FreeCAD.ActiveDocument.Body002.ViewObject.DiffuseColor = FreeCAD.ActiveDocument.Body001.ViewObject.DiffuseColor
(Use your actual object names instead of Body002 and Body001, if different)
User avatar
xsuper9988
Posts: 210
Joined: Sat Oct 24, 2020 4:20 am

Re: Request Update Feature "Draft Mirror Keeps the Same Color"

Post by xsuper9988 »

yorik wrote: Thu Jun 30, 2022 9:47 am The Draft mirror tool uses the Part mirror tool internally, which apparently doesn't map colors.
An easy fix we could do directly in Draft, is, after the object has been mirrored, copy over the colors from the original object to the mirrored object. But I am not sure the faces order is kept by the mirroring operation.. If faces order gets shuffled, face colors won't be correctly mapped.

Could you try something like this, see if we get correct results? That would help us to see if the above method would work. In the python console, enter this:

Code: Select all

FreeCAD.ActiveDocument.Body002.ViewObject.DiffuseColor = FreeCAD.ActiveDocument.Body001.ViewObject.DiffuseColor
(Use your actual object names instead of Body002 and Body001, if different)
Sorry,I don't understand console mode
I have test your command
it seems to fail

But I found that its order is regular
Bady has 18 edges
Bady001 has 3 edges
Bady002 has 3 edges

Edge12 on both sides are mirrored
My original topic has a file attached
you can test it
thanks a lot for you help
Attachments
DrafArrayColorConsole.png
DrafArrayColorConsole.png (122.78 KiB) Viewed 619 times
User avatar
Roy_043
Veteran
Posts: 5279
Joined: Thu Dec 27, 2018 12:28 pm

Re: Request Update Feature "Draft Mirror Keeps the Same Color"

Post by Roy_043 »

The Part_Mirror operation works on the Shape of the Std_Part. That is why the mirrored object is a compound of 3 solids and the numbering of its subelements is completely different from the original objects in the St_Part. Since the Std_Part does not have color properties we probably end up with a white result.
User avatar
xsuper9988
Posts: 210
Joined: Sat Oct 24, 2020 4:20 am

Re: Request Update Feature "Draft Mirror Keeps the Same Color"

Post by xsuper9988 »

Roy_043 wrote: Thu Jun 30, 2022 11:40 am The Part_Mirror operation works on the Shape of the Std_Part. That is why the mirrored object is a compound of 3 solids and the numbering of its subelements is completely different from the original objects in the St_Part. Since the Std_Part does not have color properties we probably end up with a white result.
I have a question
Array_Pattern is a similar function
But Array_Pattern can keep the same color
Is there no way for Mirror to keep the same color?
Thank you very much for your reply
Attachments
DrafArrayColor.FCStd
(20.9 KiB) Downloaded 6 times
DrafArrayColor.png
DrafArrayColor.png (112.89 KiB) Viewed 593 times
User avatar
xsuper9988
Posts: 210
Joined: Sat Oct 24, 2020 4:20 am

Re: Request Update Feature "Draft Mirror Keeps the Same Color"

Post by xsuper9988 »

Roy_043 wrote: Thu Jun 30, 2022 11:40 am The Part_Mirror operation works on the Shape of the Std_Part. That is why the mirrored object is a compound of 3 solids and the numbering of its subelements is completely different from the original objects in the St_Part. Since the Std_Part does not have color properties we probably end up with a white result.
Hi ROY
I found that maybe I got the definition of "Mirror" wrong
I shouldn't be "Request Update"
I should be "Request New Function"
The name of the new feature is "Mirror_Pattern"
It is inherited from the "Arrray_Patten" framework
Because I found that there is "Scale" in the parameter of "Arrray_Patten"
What do you think of this idea?

PS: I found that the "Scale" of "Arrray_Patten" will also turn black, so it should not be a problem with the Link object, it should be related to the "Scale" in the library, I will go to modify that topic
Attachments
RequestMirrorPattern.png
RequestMirrorPattern.png (131.34 KiB) Viewed 574 times
User avatar
xsuper9988
Posts: 210
Joined: Sat Oct 24, 2020 4:20 am

Re: Request Update Feature "Draft Mirror Keeps the Same Color"

Post by xsuper9988 »

Roy_043 wrote: Thu Jun 30, 2022 11:40 am The Part_Mirror operation works on the Shape of the Std_Part. That is why the mirrored object is a compound of 3 solids and the numbering of its subelements is completely different from the original objects in the St_Part. Since the Std_Part does not have color properties we probably end up with a white result.
@Roy_043 @yorik
I found that the Draft mirror in the LinkBranch version is colored... XD

Excuse me @realthunder
Can you help reply to this difference?

LinkBranch Ver.

Code: Select all

OS: Windows 10 Version 2009
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 2022.430.28641 (Git)
Build type: Release
Branch: LinkStage3
Hash: a77045488092c24ece25d63c91f362cbd2181d36
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: Chinese/Taiwan (zh_TW)
Attachments
LB_ScaleMirror.png
LB_ScaleMirror.png (105.68 KiB) Viewed 491 times
User avatar
yorik
Founder
Posts: 12866
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Request Update Feature "Draft Mirror Keeps the Same Color"

Post by yorik »

Thanks for testing @xsuper9988 I'll have a better look at your file...
Roy_043 wrote: Thu Jun 30, 2022 11:40 am The Part_Mirror operation works on the Shape of the Std_Part. That is why the mirrored object is a compound of 3 solids and the numbering of its subelements is completely different from the original objects in the St_Part. Since the Std_Part does not have color properties we probably end up with a white result.
The body's DiffuseColor has been fixed recently IIRC. I'll have a better look here. But indeed, a quick workaround solution might be to make individual mirrors of the different subcomponents..
User avatar
xsuper9988
Posts: 210
Joined: Sat Oct 24, 2020 4:20 am

Re: Request Update Feature "Draft Mirror Keeps the Same Color"

Post by xsuper9988 »

yorik wrote: Mon Jul 04, 2022 7:07 am The body's DiffuseColor has been fixed recently IIRC. I'll have a better look here. But indeed, a quick workaround solution might be to make individual mirrors of the different subcomponents..
Thank you very much for your contribution and help
User avatar
xsuper9988
Posts: 210
Joined: Sat Oct 24, 2020 4:20 am

Re: Request Update Feature "Draft Mirror Keeps the Same Color"

Post by xsuper9988 »

yorik wrote: Mon Jul 04, 2022 7:07 am The body's DiffuseColor has been fixed recently IIRC. I'll have a better look here. But indeed, a quick workaround solution might be to make individual mirrors of the different subcomponents..
Do I need to create a Feature Request on Github for "Draft Mirror Keeps the Same Color"?
Post Reply