首页 creo二次开发中主表示的坑

creo二次开发中主表示的坑

小白鼠 2019-07-10 10:41:00 5 5089

creo中的坑:

 ProSolidSimprepVisit 这个函数遍历只能得到默认表示的 主表示 却不能得到活动的主表示(即当前显示的主表示),那么要前面那个函数有何用??

190710_001.png190710_002.png


想要得到活动的主表示,需要用到ProSimprepActiveGet 这个函数,然后遍历所有的项数据,具体代码如下:


ProError ProUtilCollect2ParamDBVisitAction(
    void	    *p_object,	/* In:	The pointer to the object 
					being visited */
    ProAppData	    app_data)	/* In:	In fact it's ProArray** */
{
    ProError status; 
    ProArray *p_array;
    
    p_array = (ProArray*)((void**)app_data)[0];

    status = ProArrayObjectAdd(p_array, PRO_VALUE_UNUSED, 1, p_object );
    return (status);
}
ProError ProUtilCollect3ParamDBVisitAction(
    void	    *p_object,	/* In:	The pointer to the object 
					being visited */
    ProError	    status,	/* In:  The status returned by filter func */
    ProAppData	    app_data)	/* In:	In fact it's ProArray** */
{
    return (ProUtilCollect2ParamDBVisitAction(p_object, app_data));
}
ProError ProUtilCollectSimprepsdataitems( 
    ProSimprepdata   *p_simprepdata,/* In:  The simprepdata handle */
    ProSimprepitem    **p_simprepitems    /* Out: ProArray with collected simp reps
					    items. The function allocates 
					    memory for this argument, but 
					    you must free it. To free 
					    the memory, call the function 
					    ProArrayFree() */
)
{


    ProError	    status;

    if( p_simprepitems != NULL )
    {
	status = ProArrayAlloc(0,sizeof(ProSimprepitem), 1, (ProArray*)p_simprepitems);

	if( status == PRO_TK_NO_ERROR )
	{

	    status = ProSimprepdataitemsVisit( p_simprepdata, 
                (ProFunction)NULL,
		(ProFunction)ProUtilCollect3ParamDBVisitAction,
                (ProAppData)&p_simprepitems );
	    
	    if( status != PRO_TK_NO_ERROR )
	    {
		ProArrayFree( (ProArray*)p_simprepitems );
		*p_simprepitems = NULL;
	    }
	}
    }
    else
	status = PRO_TK_BAD_INPUTS;

    return (status);


}




ProError ProTestSRepItemsVisit (
    ProSimprepitem *item,
    ProSolid          solid,
    vector<ProAsmcomppath>  &arrayComPath )
{
    wchar_t wname[PRO_MDLNAME_SIZE];
    char     name[PRO_MDLNAME_SIZE];
    ProAsmcomppath comp_path;
    ProMdl    model;
    ProFeature feature;
    ProFeattype type;
    ProBoolean is_visibile;
    ProError status;

    if ( item->item_path.path_size == PRO_VALUE_UNUSED )
    {
/*--------------------------------------------------------------------*\
    Feature simp rep
\*--------------------------------------------------------------------*/
        status = ProFeatureInit(solid, item->item_path.feat_id, &feature);
    
		status = ProFeatureTypeGet(&feature, &type);
    
    
    }
    else
    {
/*--------------------------------------------------------------------*\
    Assembly simp rep
\*--------------------------------------------------------------------*/
    status = ProAsmcomppathInit(solid, item->item_path.comp_path,
                item->item_path.path_size, &comp_path);
       
    //status = ProAsmcomppathMdlGet(&comp_path, &model);
    //status = ProMdlMdlnameGet(model, wname);

    is_visibile = PRO_B_TRUE;
    status = ProAsmcompVisibilityGet( &comp_path, NULL, &is_visibile );
    
    if( status == PRO_TK_NO_ERROR && is_visibile == PRO_B_TRUE)
		arrayComPath.push_back(comp_path);

    }
    return PRO_TK_NO_ERROR;
}

//通过ProSolid 获得 主表示

此处内容已隐藏,评论后刷新即可查看!



发表评论

评论列表:

匿名
2020-12-17 17:02
谢谢分享!
匿名
2020-07-05 11:53
雷锋同志,您好
匿名
2020-05-30 08:16
谢谢分享
匿名
2020-03-22 14:57
的的撒
下雨天
2020-02-26 21:08
这个很有用,谢谢分享