cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Option to exclude features from outsize calculations.

CHASEONHO
18-Opal

Option to exclude features from outsize calculations.

Hi,

 

The Toolkit API can calculate the model's outer angle size through ProSolidOutlineCompute. This function can exclude some elements such as datum features and curves.

Surfaces and hidden features cannot be excluded from ProSolidOutlineCompute() calculations.

We'd like to hear your thoughts on ideas for solving these problems.


1. Exclude hidden features and surfaces of the active model, convert to STEP, and then RETRIVE to perform ProSolidOutlineCompute().
: It takes a lot of time
2. Use ProSolidFeatstatusGet to visit the Geomitem of features excluding surfaces and hidden features to find the minimum and maximum points of XYZ.

 

If you have any better ideas, please help.

 

Warm Regards,

SeonHo CHA.

1 ACCEPTED SOLUTION

Accepted Solutions
RPN
17-Peridot
17-Peridot
(To:CHASEONHO)

You may try do this in Memory for Parts.  First ProPartToProIntfaceData and next use ProIntfDataOutlineGet But not sure what Creo will do with One Sided Surfaces. 

An other more complicated way may, to merge a component into a separate part, for an udf I guess you can exclude a couple of item types before merge. 

Another way may also to transfer what you need in a different body. 

View solution in original post

5 REPLIES 5

This method exports the active model as an STL file and then uses the facets to calculate its size.
This method allows you to calculate the exterior size excluding surfaces.
You can also select a coordinate system to calculate the size of non-orthogonal shapes.

#define DEFAULT_ANGLE_CONTROL	0.5	
#define DEFAULT_CHORD_HEIGHT	0.05
#define DEFAULT_STEP_SIZE       0.5

ProError FacetsetFasetVisit(ProFacet facet,ProError status, ProAppData data)
{
	ProFacetVertex verties[3];
	status = ProFacetVerticesGet(facet,verties);
	if(status != PRO_TK_NO_ERROR)	return PRO_TK_NO_ERROR;
	for (int i = 0; i < 3 ; i++)
	{
		ProPoint3d point;
		status = ProFacetvertexPointGet(verties[i],point);
		if(status != PRO_TK_NO_ERROR)	break;
		for (int j = 0; j < 3; j++)
		{
			if(((Pro3dPnt*)data)[0][j] > point[j])
			{
				((Pro3dPnt*)data)[0][j] = point[j];
			}
			if(((Pro3dPnt*)data)[1][j] < point[j])
			{
				((Pro3dPnt*)data)[1][j] = point[j];
			}	
		}	
	}
	return PRO_TK_NO_ERROR;
}
ProError FacetsetFasetFilter(ProFacet facet,ProError status)
{
	return PRO_TK_NO_ERROR;
}
ProError StlFacetsetVisit(ProFacetSet *facet_set,ProError status, ProAppData data)
{
	status = ProFacetsetFacetVisit(facet_set,(ProFacetVisitAction)FacetsetFasetVisit,
		(ProFacetFilterAction)FacetsetFasetFilter,data);
	return PRO_TK_NO_ERROR;
}
ProError StlFacetsetFilter(ProFacetSet *facet_set,ProError status)
{
	return PRO_TK_NO_ERROR;
}
ProError XxOutlineCompute()
{
	ProSelection *select;
	int size = -1;
	ProError status = ProSelect("csys",-1,NULL,NULL,NULL,NULL,&select,&size);
	if(status != PRO_TK_NO_ERROR || size<1)
	{
		return PRO_TK_BAD_INPUTS;
	}
	//get select to mdl
	ProModelitem mdl_item;
	status = ProSelectionModelitemGet(select[0],&mdl_item);
	ProMdl mdl;
	status = ProModelitemMdlGet(&mdl_item,&mdl);			
	//get selected csys matrix
	ProCsys csys;
	status = ProGeomitemToCsys(&mdl_item,&csys);
	ProGeomitemdata *g_data;
	status = ProCsysDataGet(csys,&g_data);
	ProMatrix matrix;
	status = ProMatrixInit(g_data->data.p_csys_data->x_vector,
		g_data->data.p_csys_data->y_vector,
		g_data->data.p_csys_data->z_vector,
		g_data->data.p_csys_data->origin,
		matrix);
	double *quality;
	ProArrayAlloc(3, sizeof(double), 1, (ProArray*)&quality);
	quality[0] = DEFAULT_CHORD_HEIGHT;
	quality[1] = DEFAULT_ANGLE_CONTROL;
	quality[2] = DEFAULT_STEP_SIZE;

	// Configuration flag.
	int config_flags = PRO_FACET_USE_CONFIG;

	//1. ProImportExportFile exportType= PRO_SLA_BINARY_FILE to get STL in Binary format
	//2. ProImportExportFile exportType= PRO_SLA_ASCII_FILE to get STL in ASCII format
	ProImportExportFile exportType = PRO_SLA_BINARY_FILE;
	status = ProIntfSliceFileWithOptionsMdlnameExport(mdl, L"temp.stl", exportType, quality, config_flags, matrix, NULL);
	status = ProArrayFree((ProArray*)&quality);
	ProMdl p_handle;
	ProIntfImportType importType = PRO_INTF_IMPORT_STL;
	status = ProIntfimportModelWithOptionsMdlnameCreate(L"temp.stl",NULL,importType,PRO_MDL_PART,
		PRO_IMPORTREP_MASTER,L"temp",NULL,NULL,&p_handle);
	Pro3dPnt data[2];
	for (int i = 0; i < 3; i++)
	{
		data[0][i] = 9999;
		data[1][i] = -9999;
	}	
	status = ProSolidFacetsetVisit((ProSolid)p_handle,(ProFacetsetVisitAction)StlFacetsetVisit,
		(ProFacetsetFilterAction)StlFacetsetFilter,&data);
	ProMdlErase(p_handle);
	//Get model size
	double x_size = data[0][0] - data[1][0];
	double y_size = data[0][1] - data[1][1];
	double z_size = data[0][2] - data[1][2];

	return status;
}



RPN
17-Peridot
17-Peridot
(To:CHASEONHO)

You may try do this in Memory for Parts.  First ProPartToProIntfaceData and next use ProIntfDataOutlineGet But not sure what Creo will do with One Sided Surfaces. 

An other more complicated way may, to merge a component into a separate part, for an udf I guess you can exclude a couple of item types before merge. 

Another way may also to transfer what you need in a different body. 

@RPN Thanks,

 

As a result of testing with an STL file with a size of approximately 160MB, the following differences are found in calculating the outer size.
ProSolidFacetsetVisit: 17.85 seconds
ProIntfDataOutlineGet : 0.002 seconds

 

It seems like a good idea to use ProIntfDataOutlineGet after exporting to an STL file.

FV
17-Peridot
17-Peridot
(To:CHASEONHO)

Similar to #1.

Using ProSolidShrinkwrapMdlnameCreate(...) instead of STEP.

ProShrinkwrapoptionsQualitySet(...) to 2 or 3 and ProShrinkwrapoptionsIgnoresmallsurfsSet(...) to PRO_B_TRUE.

Should be much faster compared to STEP.

HIH 

CHASEONHO
18-Opal
(To:FV)

@FV , Thanks.

 

Here are the results of testing with a model with a size of 16MB:
(Model outer size: 1016.000 x 182.000 x 356.795)


■ ProSolidShrinkwrapMdlnameCreate:
-.Output time: 2.688 seconds
-.Result size: 46 KB
-.Exterior size: 1016.000 x 181.063 x 356.795

■ ProIntfSliceFileWithOptionsMdlnameExport:
-.Output time: 4.198 seconds
-.Result size: 13.6 MB
-.Exterior size: 1016.000 x 182.000 x 356.795

 

Although there is a clear time difference, I prefer using ProIntfSliceFileWithOptionsMdlnameExport for two reasons.
1. Error range of outer angle size calculation results
2. For angular shapes, calculation is possible by selecting a reference coordinate system.

CHASEONHO_0-1696383923210.png

In the case of a shape like the picture, the size of the model is calculated as the green box area based on basic coordinates. After selecting CS0 as the reference coordinate system and exporting to STL, you can calculate as much as the blue area.

Top Tags