Comments (3)
I guess related to materials @davesrocketshop FYI
from freecad.
from freecad.
Instead of setting the 'DiffuseColor' attribute directly, call the following set function, or similar, after making it available. Works on my end.
def setDiffuseColor(vObj, diffuse, transparency=None):
"""setDiffuseColor(vObj, diffuse, transparency=None)
Sets DiffuseColor and optional Transparency of vObj"""
if (isinstance(diffuse, tuple) or isinstance(diffuse, list)) and len(diffuse) == 3:
m = vObj.ShapeAppearance[0] # get current material attributes
if transparency is not None and transparency >= 0.0 and transparency <= 100.0:
t = transparency
else:
t = m.Transparency
vObj.ShapeAppearance = FreeCAD.Material(
DiffuseColor=(diffuse[0] / 255.0, diffuse[1] / 255.0, diffuse[2] / 255.0),
AmbientColor=m.AmbientColor,
SpecularColor=m.SpecularColor,
EmissiveColor=m.EmissiveColor,
Shininess=m.Shininess,
Transparency=t,
)
Just a suggestion.
Example:
setDiffuseColor(self.Body.ViewObject, (204, 204, 230))
... in place of the following:
self.Body.ViewObject.ShapeAppearance[0].DiffuseColor = (0.8, 0.8, 0.90, 0.0)
or
self.Body.ViewObject.ShapeColor = (204, 204, 230)
or
self.Body.ViewObject.ShapeAppearance.DiffuseColor = (0.8, 0.8, 0.90, 0.0)
--Throws an error.
The solution appears to be assigning a new FreeCAD.Material object to ShapeAppearance, rather than being able to edit the DiffuseColor attribute of the existing.
from freecad.
Related Issues (20)
- FreeCAD crashes with SIGSEGV when opening a specific file HOT 6
- FreeCAD - Measure angle problem HOT 2
- [Feature request][Part Design] There is no additive equivalent tool for Hole (Stud). HOT 4
- Part and PartDesign icons need reevaluation HOT 1
- [Feature Request][Part Design WB] Merge the "Internal Geometry" feature of RealThunder's Link Branch if and when multiple solids in Part Design becomes the standard HOT 1
- WB TabBar: Can only align icons or icons+text in the center.
- BIM: Error when entering measurements to walls before creating them HOT 2
- BIM: Error with Stairs HOT 1
- FreeCAD's interface freezes on linux wayland session HOT 12
- [UX]Consistency of Tools' Active and Deactivated behavior depending on what is selected
- Part Design: Cloned body not displayed correctly when base feature is changed HOT 1
- CAM: preference card needs revision [AppImage] HOT 5
- Update icons that include the FreeCAD logo
- Gui: 3D Dragger is rendered without respect to order
- FCAD 0.22.0dev - File > New not working after editing sketch HOT 2
- Checking Connection to github connect failed HOT 3
- Helix breaks over certain length HOT 6
- FreeCAD 0.21.2 | Draft Import : SVG as Geometry failed HOT 4
- DRAFT: Error Shape2DView HOT 4
- CAM: CW/CCW/Conventional/Climb terminology consistency HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freecad.