POV-Ray : Newsgroups : povray.general : CAD colors to PovRay Server Time
4 Dec 2024 14:03:38 EST (-0500)
  CAD colors to PovRay (Message 1 to 1 of 1)  
From: GioSeregni
Subject: CAD colors to PovRay
Date: 2 Dec 2023 19:25:00
Message: <web.656bca29f1166e49276109cb59126100@news.povray.org>
Hi all,
I use twuo parser working on my CAD
First, running at run time (Autolisp extension) creates triangle (two or one) by
AutoCAD 3DFACE(s) (4 sides or 3 sides).
or
Second, (exe) DXF to PovRay, in same way by 3DFACE(s).

I have been using a fairly efficient system for transmitting colors for years.
I use layer names in CAD.
In this way.
Example for white
HEXFFFFFF
If necessary I use transmit for transparency, then the "uman" layername (ignored
in the parser).
HEXFFFFFF[FF][MYLAYERNAME]

this is the code in the povray files:

full red example
triangle{<10.2649,0.0000,5.4354><5.1437,0.0000,1.2973><13.0078,0.0000,0.2667>
 pigment {color rgb hex2rgb("HEXFF0000")}
}




#macro h2d(HexVal)
 (asc(HexVal)>64?asc(HexVal)-55:asc(HexVal)-48)
#end
#macro hex2rgb(hxStr)
 <(16*h2d(substr(hxStr,4,1))+h2d(substr(hxStr,5,1)))/255,(16*h2d(substr(hxStr,6,1))+h2d(substr(hxStr,7,1)))/255,
 (16*h2d(substr(hxStr,8,1))+h2d(substr(hxStr,9,1)))/255>
#end
#macro hex2rgbT(hxStr)
 <(16*h2d(substr(hxStr,4,1))+h2d(substr(hxStr,5,1)))/255,(16*h2d(substr(hxStr,6,1))+h2d(substr(hxStr,7,1)))/255,
 (16*h2d(substr(hxStr,8,1))+h2d(substr(hxStr,9,1)))/255,((val(substr(hxStr,11,2)))/255)>
#end

Regards!
G.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.