Hi all, hope you're well
In FreeCAD if I have an oject with Appearance set with material colors etc.
How to copy and appply its appearance to other object(s)?
cheers,
Dorin
How to copy Appearance from an object to other(s)?
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Re: How to copy Appearance from an object to other(s)?
Hi DorinDXN, Greetings to the Community!
... from "settig Style" you can create a style and apply it to another object
- Attachments
-
- setting_Style.png (88.37 KiB) Viewed 762 times
Re: How to copy Appearance from an object to other(s)?
Thanks for quick reply, like I said it is about material colors.
If you select a cube in Part wrokbench then right-click and choose Appearence,
then Select Material as bronze, then click on [...] and adjust the colors...
There is no save properties as preset, nor copy.
How to apply that Appearance to other objects without going through every color?
cheers,
Dorin
If you select a cube in Part wrokbench then right-click and choose Appearence,
then Select Material as bronze, then click on [...] and adjust the colors...
There is no save properties as preset, nor copy.
How to apply that Appearance to other objects without going through every color?
cheers,
Dorin
Re: How to copy Appearance from an object to other(s)?
With a bit of Python coding, it is possible to apply one object's color to others:
Code: Select all
sel = Gui.Selection.getSelection()
sel_origin = sel[0]
color_origin = sel_origin.ViewObject.ShapeColor
if len(sel)<2:
App.Console.PrintMessage("select at least two objects")
else:
for i in sel:
if i.Name == sel_origin.Name:
pass
i.ViewObject.ShapeColor = color_origin
Use:
- Select two or more objects.
- Run the code. You can do it using a macro or just copy the code and paste it into the Python Console.
It would be possible to extend the code and add all the appearance properties that you want to be inherited.
Re: How to copy Appearance from an object to other(s)?
Thank you for reply,
I noticed only after I had an work-around I was happy with
I made some buttons on a toolbar to a set speciffic material to all selected objects
e.g. this is for black shiny Al.
cheers,
Dorin
I noticed only after I had an work-around I was happy with
I made some buttons on a toolbar to a set speciffic material to all selected objects
e.g. this is for black shiny Al.
Code: Select all
import FreeCAD as App, FreeCADGui as Gui
s=FreeCADGui.Selection.getSelection()
sc=len(s)
for p in range(sc):
if not(("Base" == App.ActiveDocument.getObject(s[p].Name).ViewObject.DisplayMode) or ("Group" == App.ActiveDocument.getObject(s[p].Name).ViewObject.DisplayMode)):
App.ActiveDocument.getObject(s[p].Name).ViewObject.DisplayMode="Shaded"
App.ActiveDocument.getObject(s[p].Name).touch()
if (hasattr(App.ActiveDocument.getObject(s[p].Name).ViewObject, 'ShapeMaterial')):
r=43
g=43
b=43
col=(r/255.0,g/255.0,b/255.0,1.0)
App.ActiveDocument.getObject(s[p].Name).ViewObject.ShapeMaterial.DiffuseColor=col
r=32
g=32
b=32
col=(r/255.0,g/255.0,b/255.0,1.0)
App.ActiveDocument.getObject(s[p].Name).ViewObject.ShapeMaterial.AmbientColor=col
r=0
g=0
b=0
col=(r/255.0,g/255.0,b/255.0,1.0)
App.ActiveDocument.getObject(s[p].Name).ViewObject.ShapeMaterial.EmissiveColor=col
r=150
g=150
b=150
col=(r/255.0,g/255.0,b/255.0,1.0)
App.ActiveDocument.getObject(s[p].Name).ViewObject.ShapeMaterial.SpecularColor=col
sn=0.99
App.ActiveDocument.getObject(s[p].Name).ViewObject.ShapeMaterial.Shininess=sn
App.ActiveDocument.getObject(s[p].Name).touch()
App.ActiveDocument.recompute()
cheers,
Dorin