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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Output feature points data

CAD_Roger
8-Gravel

Output feature points data

Hello,.I have problem,

I want to use toolkit get points data from pattern,how can I do?

點資料問題.PNG

 

 

Thanks and Regards

Roger

 

10 REPLIES 10

Hi

 

if you want to get it from pattern head:

 

 

// feat could be from a selection
pfcFeature_ptr feat = pfcFeature::cast(selectionItem);
if (feat->getFeatType() == pfcFeatureType::pfcFEATTYPE_PATTERN_HEAD) {
	pfcFeaturePattern_ptr featpat = feat->GetPattern();

	if (featpat != NULL) {
		pfcFeatures_ptr feats = featpat->ListMembers();
		if (feats != NULL) {
			for (int j = 0; j < feats->getarraysize(); j++) {
				pfcFeatureType type = feats->get(j)->GetFeatType();
				if (type == pfcFeatureType::pfcFEATTYPE_DATUM_POINT) {
					pfcSelection_ptr sel = pfcCreateModelItemSelection(pfcModelItem::cast(feats->get(j)));
          // do whatever you want with your element
					data->ref_references->append(sel);
				}
			}
		}
	}
}

Br,

Eike

hello,Eike

Can I use this method to export .txt file?

You can use it for everything with points. So it just get the pattern in and the points (inside of selections) out. So you could get the points out of the selections and then get the position out of the points.

 

You need to decide to which Coordinate system you want to recalculate the position (to be sure that it also work in Assemblies and if your main CS is not the Part root CS).

 

So in simplicity yes. That's what I do with these sniplet 🙂

 

Br,

Eike

Quesion1.PNG

I have got the selected pattern id & handle ,how can i use your method to get points coordinate system?

Oh ... it's ObjectToolkit not Toolkit but you can mix it up or translate it ...

 

For Toolkit without OTK:

If you already have selected a modelitem you should check the type and then get the members

ProPatternMemberVisit

ProPatternMembersGet

After that check if they are points, or whatever you're searching for, and then let them out by

transform them on the inverted transformation matrix of the coordinate system.

 

Br,

Eike

I used ProPatternMembersGet(), but it will automatically interrupt when my program runs here.

My program is below

q2.PNG

I guess it may be necessary to set up ProPatternMemberVisit() before ProPatternMembersGet(),but i cannot use ProPatternMemberVisit().

How can I do ?

You use one or the other.

 

...MembersGet <~ returns an array ProArraySizeGet(...) gives you the size of these

...MemberVisit <~ call a function with all members. It's an easier solution if you need recursive calls and stuff like that. But all returnvalues need to be pushed in variable / struct that you get in the ProAppData <~ void * section of the caller (preallocation would make sense).

 

Br,

Eike

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

Get rid of the „.owner„ 



extern ProError ProPatternMembersGet (ProPattern *p_pattern,
ProFeature **feat_members);
/*
Purpose: Get the member features in pattern.

Input Arguments:
p_pattern - The pattern handle

Output Arguments:
feat_members - Feature members inside the pattern
For a group pattern, this is the group header feature only.
Free this memory using ProArrayFree().

 

*/

 

 

and get the pattern first by using:

extern ProError ProFeaturePatternGet (

ProFeature *pattern_feature,
ProPatternClass pat_class,
ProPattern *p_pattern );


Pattern class identified by Feature or Group pattern.

 

Some code:

# if 4178 is a point pattern feature ID in the current model
set fp [open export.txt w]
foreach member [ps_pattern memb 4178] {
	set geomId [ps_visit feature point $member]
	ps_data point $geomId point3dObj
	puts $fp [point3dObj 3d]
}
close $fp

 

 

CAD_Roger
8-Gravel
(To:RPN)

I used ProFeaturePatternGet() and ProPatternMembersGet() , but i can only get PATTERN_LEADER.

I wnat to know Pattern Member ,how can i do?

1219-1.PNG1219-2.PNG

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

search for a function ProUtilGeomitemDump in pt_examples UtilGeom.c, copy/paste code for PRO_POINT.

 

As Eike mentioned,

use ProPatternMembers get to get a ProArray of point features

use ProFeatureGeomitemGet to get ProGeomitem which is going to be a PRO_POINT

the rest is from pt_examples

do not forget to apply appropriate transformations.

 

HIH.

FV.

 

Announcements


Top Tags