forked from GEOUNED-org/GEOUNED
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/psauvan/GEOUNED
- Loading branch information
Showing
48 changed files
with
13,962 additions
and
12,167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: 'Check that PR to main is coming from dev if necessary' | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
check_branch: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check branch | ||
if: github.base_ref == 'main' && github.head_ref != 'dev' | ||
run: | | ||
echo "ERROR: You can only merge to main from dev." | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,51 @@ | ||
import re | ||
import sys | ||
|
||
sys.path.append('/usr/lib64/freecad/lib64/') | ||
sys.path.append("/usr/lib64/freecad/lib64/") | ||
import ImportGui | ||
|
||
bd = 255 | ||
gd = 255*255 | ||
rd = 255* 255* 255 | ||
matNumber=re.compile(r"Material_(?P<matnum>\d+)") | ||
gd = 255 * 255 | ||
rd = 255 * 255 * 255 | ||
matNumber = re.compile(r"Material_(?P<matnum>\d+)") | ||
|
||
def getColor(num,vmin=0,vmax=rd): | ||
|
||
def getColor(num, vmin=0, vmax=rd): | ||
colRange = rd | ||
dnum = vmax - vmin | ||
dnum = vmax - vmin | ||
dx = num - vmin | ||
scale = colRange/dnum | ||
scale = colRange / dnum | ||
snum = dx * scale + 1 | ||
red = snum//gd | ||
r = snum - red * gd | ||
|
||
red = snum // gd | ||
r = snum - red * gd | ||
green = r // bd | ||
blue = r - green * bd | ||
return (red/255,green/255,blue/255) | ||
return (red / 255, green / 255, blue / 255) | ||
|
||
|
||
def setColorMaterial(documents): | ||
featureObj = [] | ||
matMin = 999999999 | ||
matMax = 0 | ||
for obj in documents.Objects: | ||
if obj.TypeId == 'Part::Feature' : | ||
for o in obj.InListRecursive: | ||
m = matNumber.search(o.Label) | ||
if m : | ||
mat = int(m.group('matnum')) | ||
matMin = min(matMin,mat) | ||
matMax = max(matMax,mat) | ||
featureObj.append((obj,mat)) | ||
for obj,mat in featureObj: | ||
obj.ViewObject.ShapeColor = getColor(mat,matMin,matMax) | ||
if obj.TypeId == "Part::Feature": | ||
for o in obj.InListRecursive: | ||
m = matNumber.search(o.Label) | ||
if m: | ||
mat = int(m.group("matnum")) | ||
matMin = min(matMin, mat) | ||
matMax = max(matMax, mat) | ||
featureObj.append((obj, mat)) | ||
|
||
for obj, mat in featureObj: | ||
obj.ViewObject.ShapeColor = getColor(mat, matMin, matMax) | ||
|
||
|
||
# color solids in a Freecad document with respect to the material number | ||
doc = App.ActiveDocument | ||
setColorMaterial(doc) | ||
name = doc.Label | ||
outname = name+'_color' | ||
ImportGui.export(doc.RootObjects,outname+'.stp') | ||
doc.saveAs(outname+'.FCStd') | ||
|
||
outname = name + "_color" | ||
ImportGui.export(doc.RootObjects, outname + ".stp") | ||
doc.saveAs(outname + ".FCStd") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.