几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   SolidWorks二次开发 (http://www.dimcax.com/hust/forumdisplay.php?f=111)
-   -   【转帖】getting all the colors of components and parts (http://www.dimcax.com/hust/showthread.php?t=5364)

yang686526 2009-04-13 11:04 AM

【转帖】getting all the colors of components and parts
 
getting all the colors of components and parts
how do i get all the colors of a component or a part? i tried getmaterialpropertyvalues function but it is not working.
please help. thanks in advance
sw 2007 office premium sp1.0
hi,
try this macro:
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swbody as sldworks.body2
dim vbodyarr as variant
dim vbody as variant
dim vmatprop as variant
dim i as long
sub main()
set swapp = application.sldworks
set swmodel = swapp.activedoc
for i = 0 to 5
vbodyarr = swmodel.getbodies2(i, false)
if not isempty(vbodyarr) then
for each vbody in vbodyarr
set swbody = vbody
vmatprop = swbody.materialpropertyvalues2
if not isempty(vmatprop) then
msgbox ("rgb = [" & vmatprop(0) * 255# & ", " & vmatprop(1) * 255# & ", " & vmatprop(2) * 255# & "]")
end if
next
end if
next i
end sub
thanks,
artem


所有的时间均为北京时间。 现在的时间是 07:02 PM.