几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【求助】SolidWorks2006 获得草图颜色 (http://www.dimcax.com/hust/showthread.php?t=966)

hello098 2007-06-18 11:54 AM

【求助】SolidWorks2006 获得草图颜色
 
我用Feature::GetMaterialPropertyValues2 函数用在草图上是得不到颜色的,输出的double数组的值都是-1。Feature::GetMaterialPropertyValues 也得不到真实的Sketch颜色,请各位帮帮忙能不能用别的方法得到。

yogy 2007-06-18 03:03 PM

回复: 【求助】SolidWorks2006 获得草图颜色
 
1) 遍历特征树
// get the feature type name
featureTypeName = swFeature.GetTypeName();
2)判断是否为草图类型
if ( 0 != featureTypeName.Compare(_T("OriginProfileFeature")) )
3)从草图获取sketchSegment
vSketchSegments = swSketch.GetSketchSegments();
4)获取草图的颜色
ISketchSegment::GetColor

hello098 2007-06-19 08:13 AM

回复: 【求助】SolidWorks2006 获得草图颜色
 
谢谢yogy!我试了一下,还是不行,SolidWork API help 里说

SketchSegment 的 get_Color() 只是对Drawing有效的

我在Part里用 无论设置Sketch为什么颜色,得到的都是同一个颜色值
long 8421504 您看看还有没其他的方法??再次感谢!!:)

yogy 2007-06-19 10:46 AM

回复: 【求助】SolidWorks2006 获得草图颜色
 
我测试和trace代码先。wait
~~~
测试结果如下:
我通过上述遍历的代码,偶尔能得到草图的不同颜色值。确实有时值不对!看来是SolidWorks的BUG。
建议:
1) open model 之后 rebuild
swRebuildOptions_e rebuildOptions = swRebuildAll; // rebuild any geometry not regenerated
swModelDoc.Rebuild (rebuildOptions);
2) 去除材质
3) 草图若是白色(255,255,255),总得到深灰色的值。

PS:8421504 对应 128,128,128 深灰色

yogy 2007-06-22 12:01 PM

回复: 【求助】SolidWorks2006 获得草图颜色
 
方便的话,写英文Email直接问API的技术支持吧!
apisupport@solidworks.com

hello098 2007-06-22 01:34 PM

回复: 【求助】SolidWorks2006 获得草图颜色
 
多谢了!! 我回去试一下。

yogy 2007-06-23 02:02 PM

回复: 【求助】SolidWorks2006 获得草图颜色
 
一、设置面的颜色
要考虑颜色获取的优先级
1)得到系统级别的颜色设置
//Use the integer user-preference enumerations to get and set system-level or document-level settings and options. SldWorks::GetUserPreferenceIntegerValue and SldWorks::SetUserPreferenceIntegerValue get and set system-level settings and options; ModelDoc2::GetUserPreferenceIntegerValue and ModelDoc2::SetUserPreferenceIntegerValue get and set document-level settings and options. ((from SW_API help doc))
// system option: get the default shading color for the body
defaultRGBColor = swModelDoc.GetUserPreferenceIntegerValue (185 /*swDocumentColorShading*/);
2)得到模型的材质
//This property gets or sets a material's properties in the active configuration. The material values include the color (R,G,B values), reflectivity (ambient, diffuse, specular, shininess), transparency and emission. (from SW_API help doc)
// // get the default display properties of the model If one exists, it's
// color overrides the default shading color
m_vParameters = swModelDoc.GetMaterialPropertyValues();
3)得到feature的材质
4)得到face的材质


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