|
想用它来创建两条直线之间的距离,但是怎么弄都会报错,返回PRO_TK_BAD_DIM_ATTACH,各位大佬帮忙看看
ProMdl model_dis ;
ProSelection *p_sel_dis ;
ProSelection *p_sel_ann;
int n_sel_dis ;
int n_sel_ann;
ProFileName msg_file ;
ProDimAttachment p_dim_attach;
ProDimSense *p_dim_sense;
Pro3dPnt P_dim_3dPnt1,P_dim_3dPnt2,P_dim_3dPnt3;
ProDimension p_dimension_new;
ProAnnotationPlane p_ann_plane;
int err ;
ProArrayAlloc(2, sizeof(ProDimSense), 1, (ProArray*)&p_dim_sense);
ProArrayAlloc(1, sizeof(ProSelection), 1, (ProArray*)&p_sel_dis);
p_dim_sense[0].type=PRO_DIM_SNS_TYP_NONE;
p_dim_sense[0].orient_hint=PRO_DIM_ORNT_NONE;
p_dim_sense[1].type=PRO_DIM_SNS_TYP_NONE;
p_dim_sense[1].orient_hint=PRO_DIM_ORNT_NONE;
ProStringToWstring(msg_file, "msg_ugfund.txt") ;
//获得当前模型.
err = ProMdlCurrentGet(&model_dis);//ProDrawing是ProMdl的子对象
if (err != PRO_TK_NO_ERROR)
{
ProMessageDisplay(msg_file, "USER %0s F", "请先打开一个模型.");
return ;
}
ProSolid solid_dis;
err = ProMdlCurrentGet((ProMdl*)&solid_dis);
ProMessageDisplay(msg_file, "USER %0s F", "选择注释.");
err = ProSelect((char*)"surface", 1, NULL, NULL, NULL, NULL, &p_sel_ann, &n_sel_ann) ; //edge,point,curve,surface
if ( err != PRO_TK_NO_ERROR )
{
ProMessageDisplay(msg_file, "USER %0s F", "取消选择特征.") ;
return ;
}
ProModelitem model_of_sel;
ProGeomitemdata ** geoitem_of_surf;
ProVector vector_of_surf;
ProArrayAlloc(1, sizeof(ProGeomitemdata*), 1, (ProArray*)&geoitem_of_surf);
err=ProSelectionModelitemGet(p_sel_ann[0],&model_of_sel);
err=ProGeomitemdataGet((ProGeomitem*)&model_of_sel,geoitem_of_surf);
if(err != PRO_TK_NO_ERROR)
if ((*geoitem_of_surf)->data.p_surface_data->type==PRO_SRF_PLANE)
{
memcpy (vector_of_surf, (*geoitem_of_surf)->data.p_surface_data->srf_shape.plane.e2, sizeof (ProVector));
}
err = ProAnnotationplaneCreate(p_sel_ann[0], vector_of_surf,&p_ann_plane);
ProMessageDisplay(msg_file, "USER %0s F", "选择需要注释的尺寸.");
for (int i=0;i<2;i++)
{
ProMessageDisplay(msg_file, "USER %0s F", "选择需要注释的尺寸.");
err = ProSelect((char*)"edge", 1, NULL, NULL, NULL, NULL, &p_sel_dis, &n_sel_dis) ; //edge,point,curve,surface
err=ProSelectionCopy(p_sel_dis[0],&p_dim_attach[i]);
}
err = ProSelectionPoint3dGet(p_dim_attach[0],(ProPoint3d)P_dim_3dPnt1);
err = ProSelectionPoint3dGet(p_dim_attach[1],(ProPoint3d)P_dim_3dPnt2);
for (int i=0;i<3;i++)
{
P_dim_3dPnt3[i]=(P_dim_3dPnt1[i]+P_dim_3dPnt2[i])/2;
}
err = ProDimensionCreate((ProSolid)solid_dis, PRO_REF_DIMENSION, &p_ann_plane, &p_dim_attach,
(ProDimSense*)p_dim_sense, PRO_DIM_ORNT_NONE,P_dim_3dPnt3,&p_dimension_new );
if(err ==PRO_TK_NO_ERROR)
{
AfxMessageBox("d7");
}
else if(err == PRO_TK_BAD_INPUTS)
{
AfxMessageBox("d8");
}
else if(err==PRO_TK_BAD_DIM_ATTACH)
{
AfxMessageBox("d9");
}
err = ProAnnotationShow((ProAnnotation*)&p_dimension_new,NULL,NULL); |
|