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

Creo Object Toolkit, WCreateFeature

DV_9803668
4-Participant

Creo Object Toolkit, WCreateFeature

Hello, 

 

I'm trying to perform a simple feature creation opertaion using the wfcWSolid::WCreateFeature function in otk. 

The feature element tree has been generated using the cxx element tree generator provided by PTC and is meant to create a default coordinate system in a part. Here is the element tree def: 

 

wfcElements_ptr CreateDefaultCoord(pfcModel_ptr Model)
{
	wfcElements_ptr newElems = new wfcElements();
	wfcElement_ptr newElem;
	CreateElem localElem;
	otkxEnums localEnum;
	CollectionHelpers localCollnHelper;

	/*	  Element id:	386 : PRO_E_FEATURE_TREE	*/
	localElem.CreateCompoundElem(PRO_E_FEATURE_TREE, 0, newElems);

	/*	  Element id:	387 : PRO_E_FEATURE_TYPE	*/
	localElem.CreateIntegerElem(PRO_E_FEATURE_TYPE, 979, 1, newElems);

	/*	  Element id:	1964 : PRO_E_STD_FEATURE_NAME	*/
	localElem.CreateStringElem(PRO_E_STD_FEATURE_NAME, "CS0", 1, newElems);

	/*	  Element id:	2134 : PRO_E_CSYS_ORIGIN_CONSTRS	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIGIN_CONSTRS, 1, newElems);

	/*	  Element id:	2147 : PRO_E_CSYS_OFFSET_TYPE	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_OFFSET_TYPE, 0, 1, newElems);

	/*	  Element id:	3953 : PRO_E_CSYS_ONSURF_TYPE	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ONSURF_TYPE, 0, 1, newElems);

	/*	  Element id:	3954 : PRO_E_CSYS_DIM_CONSTRS	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_DIM_CONSTRS, 1, newElems);

	/*	  Element id:	2137 : PRO_E_CSYS_ORIENTMOVES	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIENTMOVES, 1, newElems);

	/*	  Element id:	3054 : PRO_E_CSYS_NORMAL_TO_SCREEN	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_NORMAL_TO_SCREEN, 0, 1, newElems);

	/*	  Element id:	3050 : PRO_E_CSYS_ORIENT_BY_METHOD	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENT_BY_METHOD, 0, 1, newElems);

	/*	  Element id:	2142 : PRO_E_CSYS_ORIENTSELAXIS1_REF	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIENTSELAXIS1_REF, 1, newElems);

	/*	  Element id:	3167 : PRO_E_CSYS_ORIENTSELAXIS1_REF_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS1_REF_OPT, 0, 1, newElems);

	/*	  Element id:	2143 : PRO_E_CSYS_ORIENTSELAXIS1_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS1_OPT, 0, 1, newElems);

	/*	  Element id:	3052 : PRO_E_CSYS_ORIENTSELAXIS1_FLIP	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS1_FLIP, 0, 1, newElems);

	/*	  Element id:	2144 : PRO_E_CSYS_ORIENTSELAXIS2_REF	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIENTSELAXIS2_REF, 1, newElems);

	/*	  Element id:	3168 : PRO_E_CSYS_ORIENTSELAXIS2_REF_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS2_REF_OPT, 0, 1, newElems);

	/*	  Element id:	2145 : PRO_E_CSYS_ORIENTSELAXIS2_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS2_OPT, 0, 1, newElems);

	/*	  Element id:	3053 : PRO_E_CSYS_ORIENTSELAXIS2_FLIP	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS2_FLIP, 0, 1, newElems);

	/*	  Element id:	4123 : PRO_E_CSYS_ORIENTSELAXIS2_ROT_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS2_ROT_OPT, 0, 1, newElems);

	/*	  Element id:	4124 : PRO_E_CSYS_ORIENTSELAXIS2_ROT	*/
	localElem.CreateDoubleElem(PRO_E_CSYS_ORIENTSELAXIS2_ROT, 0, 1, newElems);

	/*	  Element id:	3051 : PRO_E_CSYS_TYPE_MECH	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_TYPE_MECH, 0, 1, newElems);

	/*	  Element id:	3932 : PRO_E_CSYS_FOLLOW_SRF_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_FOLLOW_SRF_OPT, 0, 1, newElems);

	/*	  Element id:	6133 : PRO_E_CSYS_NAME_DISPLAY_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_NAME_DISPLAY_OPT, 1, 1, newElems);

	/*	  Element id:	6140 : PRO_E_CSYS_DISPLAY_ZOOM_DEP_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_DISPLAY_ZOOM_DEP_OPT, 0, 1, newElems);

	/*	  Element id:	6139 : PRO_E_CSYS_AXIS_LENGTH	*/
	localElem.CreateDoubleElem(PRO_E_CSYS_AXIS_LENGTH, 0, 1, newElems);

	return (newElems);
}

 

 

Below is the remaining code for creating the element tree and adding it to a part solid. The issue is that this code crashes at the WCreateFeature line: 

 

 

...
part = pfcPart::cast(wfcGetObjectFromHandle(wfcProMdlHandle, (void*)pro_part));

pfcModel_ptr model = pfcModel::cast(part);
wfcWSolid_ptr wSolid_ptr = wfcWSolid::cast(model);
#pragma endregion

#pragma region Create Coordinate System

wfcFeatCreateOptions_ptr featOpts = wfcFeatCreateOptions::create();
featOpts->append(wfcFeatCreateOption_nil);

wfcWRegenInstructions_ptr regenInstr = wfcWRegenInstructions::Create();

wfcElements_ptr elements = CreateDefaultCoord(model);
wfcElementTree_ptr elementTree = session->CreateElementTree(elements);
	
try
{
	wfcWFeature_ptr feature = wSolid_ptr->WCreateFeature(elementTree, featOpts, regenInstr); <-- Crash
}
catch (const std::exception& e)
{
	throw e;
}
...

 

 

Do you have any idea of why this does not work?

 

Kind Regards

Daniel

1 ACCEPTED SOLUTION

Accepted Solutions
DV_9803668
4-Participant
(To:DV_9803668)

Solved this issue by first creating dtm planes and then the coord using the following element tree:

 

wfcElements_ptr CreateFeature_7(pfcModel_ptr Model)
{
	wfcElements_ptr newElems = new wfcElements();
	wfcElement_ptr newElem;
	CreateElem localElem;
	otkxEnums localEnum;
	CollectionHelpers localCollnHelper;

	/*	  Element id:	386 : PRO_E_FEATURE_TREE	*/
	localElem.CreateCompoundElem(PRO_E_FEATURE_TREE, 0, newElems);

	/*	  Element id:	387 : PRO_E_FEATURE_TYPE	*/
	localElem.CreateIntegerElem(PRO_E_FEATURE_TYPE, 979, 1, newElems);

	/*	  Element id:	1964 : PRO_E_STD_FEATURE_NAME	*/
	localElem.CreateStringElem(PRO_E_STD_FEATURE_NAME, "CS1", 1, newElems);

	/*	  Element id:	2134 : PRO_E_CSYS_ORIGIN_CONSTRS	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIGIN_CONSTRS, 1, newElems);

	/*	  Element id:	2135 : PRO_E_CSYS_ORIGIN_CONSTR	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIGIN_CONSTR, 2, newElems);

	/*	  Element id:	2136 : PRO_E_CSYS_ORIGIN_CONSTR_REF	*/
	localElem.CreateSelectionElem(PRO_E_CSYS_ORIGIN_CONSTR_REF, 3, Model, 1, 2, newElems);

	/*	  Element id:	2135 : PRO_E_CSYS_ORIGIN_CONSTR	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIGIN_CONSTR, 2, newElems);

	/*	  Element id:	2136 : PRO_E_CSYS_ORIGIN_CONSTR_REF	*/
	localElem.CreateSelectionElem(PRO_E_CSYS_ORIGIN_CONSTR_REF, 3, Model, 1, 4, newElems);

	/*	  Element id:	2135 : PRO_E_CSYS_ORIGIN_CONSTR	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIGIN_CONSTR, 2, newElems);

	/*	  Element id:	2136 : PRO_E_CSYS_ORIGIN_CONSTR_REF	*/
	localElem.CreateSelectionElem(PRO_E_CSYS_ORIGIN_CONSTR_REF, 3, Model, 1, 6, newElems);

	/*	  Element id:	2147 : PRO_E_CSYS_OFFSET_TYPE	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_OFFSET_TYPE, 0, 1, newElems);

	/*	  Element id:	3953 : PRO_E_CSYS_ONSURF_TYPE	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ONSURF_TYPE, 0, 1, newElems);

	/*	  Element id:	3954 : PRO_E_CSYS_DIM_CONSTRS	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_DIM_CONSTRS, 1, newElems);

	/*	  Element id:	2137 : PRO_E_CSYS_ORIENTMOVES	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIENTMOVES, 1, newElems);

	/*	  Element id:	3054 : PRO_E_CSYS_NORMAL_TO_SCREEN	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_NORMAL_TO_SCREEN, 0, 1, newElems);

	/*	  Element id:	3050 : PRO_E_CSYS_ORIENT_BY_METHOD	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENT_BY_METHOD, 0, 1, newElems);

	/*	  Element id:	2142 : PRO_E_CSYS_ORIENTSELAXIS1_REF	*/
	localElem.CreateSelectionElem(PRO_E_CSYS_ORIENTSELAXIS1_REF, 1, Model, 1, 2, newElems);

	/*	  Element id:	3167 : PRO_E_CSYS_ORIENTSELAXIS1_REF_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS1_REF_OPT, 0, 1, newElems);

	/*	  Element id:	2143 : PRO_E_CSYS_ORIENTSELAXIS1_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS1_OPT, 0, 1, newElems);

	/*	  Element id:	3052 : PRO_E_CSYS_ORIENTSELAXIS1_FLIP	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS1_FLIP, 0, 1, newElems);

	/*	  Element id:	2144 : PRO_E_CSYS_ORIENTSELAXIS2_REF	*/
	localElem.CreateSelectionElem(PRO_E_CSYS_ORIENTSELAXIS2_REF, 1, Model, 1, 4, newElems);

	/*	  Element id:	3168 : PRO_E_CSYS_ORIENTSELAXIS2_REF_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS2_REF_OPT, 0, 1, newElems);

	/*	  Element id:	2145 : PRO_E_CSYS_ORIENTSELAXIS2_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS2_OPT, 1, 1, newElems);

	/*	  Element id:	3053 : PRO_E_CSYS_ORIENTSELAXIS2_FLIP	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS2_FLIP, 0, 1, newElems);

	/*	  Element id:	4123 : PRO_E_CSYS_ORIENTSELAXIS2_ROT_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS2_ROT_OPT, 0, 1, newElems);

	/*	  Element id:	4124 : PRO_E_CSYS_ORIENTSELAXIS2_ROT	*/
	localElem.CreateDoubleElem(PRO_E_CSYS_ORIENTSELAXIS2_ROT, 0, 1, newElems);

	/*	  Element id:	3051 : PRO_E_CSYS_TYPE_MECH	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_TYPE_MECH, 0, 1, newElems);

	/*	  Element id:	3932 : PRO_E_CSYS_FOLLOW_SRF_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_FOLLOW_SRF_OPT, 0, 1, newElems);

	/*	  Element id:	6133 : PRO_E_CSYS_NAME_DISPLAY_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_NAME_DISPLAY_OPT, 1, 1, newElems);

	/*	  Element id:	6140 : PRO_E_CSYS_DISPLAY_ZOOM_DEP_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_DISPLAY_ZOOM_DEP_OPT, 0, 1, newElems);

	/*	  Element id:	6139 : PRO_E_CSYS_AXIS_LENGTH	*/
	localElem.CreateDoubleElem(PRO_E_CSYS_AXIS_LENGTH, 0, 1, newElems);


	return (newElems);
}

 

Thanks to everyone who participate in helping me out!

 

Regards

Daniel

View solution in original post

10 REPLIES 10
FV
17-Peridot
17-Peridot
(To:DV_9803668)

wfcElements_ptr CreateDefaultCoord(pfcModel_ptr Model)

this one is questionable - returning a pointer to an object  which supposedly keeps a record of its references, while the pointed object goes out of scope... 

 

CreateElem localElem;

this one is also questionable - some kind of a 'helper' instance initiated on stack. Impossible to know if it is doing what it should be doing... 

 

would be a good idea to serialize elementTree  after this call:

wfcElementTree_ptr elementTree = session->CreateElementTree(elements);

 to see if a tree was populated and if it was a valid one.

 

also, enum's are from pro/toolkit and the code looks like it had been written in otk_cpp style.

DV_9803668
4-Participant
(To:FV)

Your first point might have something to do with it, but my hesitation to believe so is that the code you've mentioned is created by PTC. 

 

Removing 

 

 

CreateElem localElem;

 

 

Equals the same error. 

A deserialized version looks like this:

 

 

<?xml version="1.0" encoding="UTF-8"?>
<PRO_E_FEATURE_TREE  AppName="Pro/ENGINEER" AppVersion="6.0"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:noNamespaceSchemaLocation="ProTKFeature.xsd" type="compound">
  <PRO_E_FEATURE_TYPE type="int">PRO_FEAT_CSYS</PRO_E_FEATURE_TYPE>
  <PRO_E_STD_FEATURE_NAME type="wstring">CS0</PRO_E_STD_FEATURE_NAME>
  <PRO_E_CSYS_ORIGIN_CONSTRS type="array">
  </PRO_E_CSYS_ORIGIN_CONSTRS>
  <PRO_E_CSYS_OFFSET_TYPE type="int">0</PRO_E_CSYS_OFFSET_TYPE>
  <PRO_E_CSYS_ONSURF_TYPE type="int">0</PRO_E_CSYS_ONSURF_TYPE>
  <PRO_E_CSYS_DIM_CONSTRS type="array">
  </PRO_E_CSYS_DIM_CONSTRS>
  <PRO_E_CSYS_ORIENTMOVES type="array">
  </PRO_E_CSYS_ORIENTMOVES>
  <PRO_E_CSYS_NORMAL_TO_SCREEN type="int">0</PRO_E_CSYS_NORMAL_TO_SCREEN>
  <PRO_E_CSYS_ORIENT_BY_METHOD type="int">0</PRO_E_CSYS_ORIENT_BY_METHOD>
  <PRO_E_CSYS_ORIENTSELAXIS1_REF></PRO_E_CSYS_ORIENTSELAXIS1_REF>
  <PRO_E_CSYS_ORIENTSELAXIS1_REF_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS1_REF_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS1_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS1_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS1_FLIP type="int">0</PRO_E_CSYS_ORIENTSELAXIS1_FLIP>
  <PRO_E_CSYS_ORIENTSELAXIS2_REF></PRO_E_CSYS_ORIENTSELAXIS2_REF>
  <PRO_E_CSYS_ORIENTSELAXIS2_REF_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS2_REF_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS2_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS2_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS2_FLIP type="int">0</PRO_E_CSYS_ORIENTSELAXIS2_FLIP>
  <PRO_E_CSYS_ORIENTSELAXIS2_ROT_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS2_ROT_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS2_ROT type="double">0.000000</PRO_E_CSYS_ORIENTSELAXIS2_ROT>
  <PRO_E_CSYS_TYPE_MECH type="int">0</PRO_E_CSYS_TYPE_MECH>
  <PRO_E_CSYS_FOLLOW_SRF_OPT type="int">0</PRO_E_CSYS_FOLLOW_SRF_OPT>
  <PRO_E_CSYS_NAME_DISPLAY_OPT type="int">1</PRO_E_CSYS_NAME_DISPLAY_OPT>
  <PRO_E_CSYS_DISPLAY_ZOOM_DEP_OPT type="int">0</PRO_E_CSYS_DISPLAY_ZOOM_DEP_OPT>
  <PRO_E_CSYS_AXIS_LENGTH type="double">0.000000</PRO_E_CSYS_AXIS_LENGTH>
</PRO_E_FEATURE_TREE>

 

 

 

Further details are that the error is of class pfcXToolkitGeneralError.

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

PRO_E_CSYS_ORIENTSELAXIS1_REF and PRO_E_CSYS_ORIENTSELAXIS2_REF must have 'selection' type in XML.

The shown XML output had listed them as 'null'

I would check this statement.

/*	  Element id:	2142 : PRO_E_CSYS_ORIENTSELAXIS1_REF	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIENTSELAXIS1_REF, 1, newElems);

 

This code does not match what the equivalent Pro/Toolkit code would or should be doing behind the scenes.

In Pro/Toolkit those elements should be created with ProElementReferenceSet with ProReference ref = NULL;  (in versions prior to Creo 4 one would need to allocate ref with ProReferenceAlloc(&ref); as well).

 

HIH.

DV_9803668
4-Participant
(To:FV)

Well identified, I've observed a difference between what the 

WriteElementTreeToFile() method outputs and what CreateElementTreeFromXML() -> WriteElementTreeToFile() outputs. 
I ran the OTKXWriteFeatAsCxx on a coordinate system with WriteElementTreeToFile() added to the process and the output was following: 
<?xml version="1.0" encoding="UTF-8"?>
<PRO_E_FEATURE_TREE  AppName="Pro/ENGINEER" AppVersion="6.0"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:noNamespaceSchemaLocation="ProTKFeature.xsd" type="compound">
  <PRO_E_FEATURE_TYPE type="int">PRO_FEAT_CSYS</PRO_E_FEATURE_TYPE>
  <PRO_E_STD_FEATURE_NAME type="wstring">DEFAULT</PRO_E_STD_FEATURE_NAME>
  <PRO_E_CSYS_ORIGIN_CONSTRS type="array">
  </PRO_E_CSYS_ORIGIN_CONSTRS>
  <PRO_E_CSYS_OFFSET_TYPE type="int">0</PRO_E_CSYS_OFFSET_TYPE>
  <PRO_E_CSYS_ONSURF_TYPE type="int">0</PRO_E_CSYS_ONSURF_TYPE>
  <PRO_E_CSYS_DIM_CONSTRS type="array">
  </PRO_E_CSYS_DIM_CONSTRS>
  <PRO_E_CSYS_ORIENTMOVES type="array">
  </PRO_E_CSYS_ORIENTMOVES>
  <PRO_E_CSYS_NORMAL_TO_SCREEN type="int">0</PRO_E_CSYS_NORMAL_TO_SCREEN>
  <PRO_E_CSYS_ORIENT_BY_METHOD type="int">0</PRO_E_CSYS_ORIENT_BY_METHOD>
  <PRO_E_CSYS_ORIENTSELAXIS1_REF type="selection"></PRO_E_CSYS_ORIENTSELAXIS1_REF>
  <PRO_E_CSYS_ORIENTSELAXIS1_REF_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS1_REF_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS1_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS1_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS1_FLIP type="int">0</PRO_E_CSYS_ORIENTSELAXIS1_FLIP>
  <PRO_E_CSYS_ORIENTSELAXIS2_REF type="selection"></PRO_E_CSYS_ORIENTSELAXIS2_REF>
  <PRO_E_CSYS_ORIENTSELAXIS2_REF_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS2_REF_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS2_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS2_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS2_FLIP type="int">0</PRO_E_CSYS_ORIENTSELAXIS2_FLIP>
  <PRO_E_CSYS_ORIENTSELAXIS2_ROT_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS2_ROT_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS2_ROT type="double">0.000000</PRO_E_CSYS_ORIENTSELAXIS2_ROT>
  <PRO_E_CSYS_TYPE_MECH type="int">0</PRO_E_CSYS_TYPE_MECH>
  <PRO_E_CSYS_FOLLOW_SRF_OPT type="int">0</PRO_E_CSYS_FOLLOW_SRF_OPT>
  <PRO_E_CSYS_NAME_DISPLAY_OPT type="int">1</PRO_E_CSYS_NAME_DISPLAY_OPT>
  <PRO_E_CSYS_DISPLAY_ZOOM_DEP_OPT type="int">0</PRO_E_CSYS_DISPLAY_ZOOM_DEP_OPT>
  <PRO_E_CSYS_AXIS_LENGTH type="double">0.000000</PRO_E_CSYS_AXIS_LENGTH>
</PRO_E_FEATURE_TREE>

 

If this is then loaded with CreateElementTreeFromXML() and saved with WriteElementTreeToFile() the following is written:

<?xml version="1.0" encoding="UTF-8"?>
<PRO_E_FEATURE_TREE  AppName="Pro/ENGINEER" AppVersion="6.0"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:noNamespaceSchemaLocation="ProTKFeature.xsd" type="compound">
  <PRO_E_FEATURE_TYPE type="int">PRO_FEAT_CSYS</PRO_E_FEATURE_TYPE>
  <PRO_E_STD_FEATURE_NAME type="wstring">DEFAULT</PRO_E_STD_FEATURE_NAME>
  <PRO_E_CSYS_ORIGIN_CONSTRS type="array">
  </PRO_E_CSYS_ORIGIN_CONSTRS>
  <PRO_E_CSYS_OFFSET_TYPE type="int">0</PRO_E_CSYS_OFFSET_TYPE>
  <PRO_E_CSYS_ONSURF_TYPE type="int">0</PRO_E_CSYS_ONSURF_TYPE>
  <PRO_E_CSYS_DIM_CONSTRS type="array">
  </PRO_E_CSYS_DIM_CONSTRS>
  <PRO_E_CSYS_ORIENTMOVES type="array">
  </PRO_E_CSYS_ORIENTMOVES>
  <PRO_E_CSYS_NORMAL_TO_SCREEN type="int">0</PRO_E_CSYS_NORMAL_TO_SCREEN>
  <PRO_E_CSYS_ORIENT_BY_METHOD type="int">0</PRO_E_CSYS_ORIENT_BY_METHOD>
  <PRO_E_CSYS_ORIENTSELAXIS1_REF_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS1_REF_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS1_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS1_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS1_FLIP type="int">0</PRO_E_CSYS_ORIENTSELAXIS1_FLIP>
  <PRO_E_CSYS_ORIENTSELAXIS2_REF_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS2_REF_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS2_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS2_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS2_FLIP type="int">0</PRO_E_CSYS_ORIENTSELAXIS2_FLIP>
  <PRO_E_CSYS_ORIENTSELAXIS2_ROT_OPT type="int">0</PRO_E_CSYS_ORIENTSELAXIS2_ROT_OPT>
  <PRO_E_CSYS_ORIENTSELAXIS2_ROT type="double">0.000000</PRO_E_CSYS_ORIENTSELAXIS2_ROT>
  <PRO_E_CSYS_TYPE_MECH type="int">0</PRO_E_CSYS_TYPE_MECH>
  <PRO_E_CSYS_FOLLOW_SRF_OPT type="int">0</PRO_E_CSYS_FOLLOW_SRF_OPT>
  <PRO_E_CSYS_NAME_DISPLAY_OPT type="int">1</PRO_E_CSYS_NAME_DISPLAY_OPT>
  <PRO_E_CSYS_DISPLAY_ZOOM_DEP_OPT type="int">0</PRO_E_CSYS_DISPLAY_ZOOM_DEP_OPT>
  <PRO_E_CSYS_AXIS_LENGTH type="double">0.000000</PRO_E_CSYS_AXIS_LENGTH>
</PRO_E_FEATURE_TREE>

But I cant verify if this is the root cause. 

RPN
14-Alexandrite
14-Alexandrite
(To:DV_9803668)

You try this, with an empty part? I guess this feature requires to be in insert mode (if the part is not empty), and it should be feature #1. And the feature name needs to be unique as well, only to be mentioned. 

DV_9803668
4-Participant
(To:RPN)

This is done with a empty part, so the feature should be unique. 

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


@DV_9803668 wrote:

This is done with a empty part, so the feature should be unique. 


write a default csys feature tree into an xml file. Make a datum plane in an empty part and add a default csys after the plane with CreateElementTreeFromXML(...) . Delete the plane. 

 

DV_9803668
4-Participant
(To:FV)

Did you succeeded doing this programatically? I tried it and it work with creating the dtm planes, but it still crashes at the creation of the dtm CSYS.

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

works fine using Pro/Toolkit API's...

DV_9803668
4-Participant
(To:DV_9803668)

Solved this issue by first creating dtm planes and then the coord using the following element tree:

 

wfcElements_ptr CreateFeature_7(pfcModel_ptr Model)
{
	wfcElements_ptr newElems = new wfcElements();
	wfcElement_ptr newElem;
	CreateElem localElem;
	otkxEnums localEnum;
	CollectionHelpers localCollnHelper;

	/*	  Element id:	386 : PRO_E_FEATURE_TREE	*/
	localElem.CreateCompoundElem(PRO_E_FEATURE_TREE, 0, newElems);

	/*	  Element id:	387 : PRO_E_FEATURE_TYPE	*/
	localElem.CreateIntegerElem(PRO_E_FEATURE_TYPE, 979, 1, newElems);

	/*	  Element id:	1964 : PRO_E_STD_FEATURE_NAME	*/
	localElem.CreateStringElem(PRO_E_STD_FEATURE_NAME, "CS1", 1, newElems);

	/*	  Element id:	2134 : PRO_E_CSYS_ORIGIN_CONSTRS	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIGIN_CONSTRS, 1, newElems);

	/*	  Element id:	2135 : PRO_E_CSYS_ORIGIN_CONSTR	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIGIN_CONSTR, 2, newElems);

	/*	  Element id:	2136 : PRO_E_CSYS_ORIGIN_CONSTR_REF	*/
	localElem.CreateSelectionElem(PRO_E_CSYS_ORIGIN_CONSTR_REF, 3, Model, 1, 2, newElems);

	/*	  Element id:	2135 : PRO_E_CSYS_ORIGIN_CONSTR	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIGIN_CONSTR, 2, newElems);

	/*	  Element id:	2136 : PRO_E_CSYS_ORIGIN_CONSTR_REF	*/
	localElem.CreateSelectionElem(PRO_E_CSYS_ORIGIN_CONSTR_REF, 3, Model, 1, 4, newElems);

	/*	  Element id:	2135 : PRO_E_CSYS_ORIGIN_CONSTR	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIGIN_CONSTR, 2, newElems);

	/*	  Element id:	2136 : PRO_E_CSYS_ORIGIN_CONSTR_REF	*/
	localElem.CreateSelectionElem(PRO_E_CSYS_ORIGIN_CONSTR_REF, 3, Model, 1, 6, newElems);

	/*	  Element id:	2147 : PRO_E_CSYS_OFFSET_TYPE	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_OFFSET_TYPE, 0, 1, newElems);

	/*	  Element id:	3953 : PRO_E_CSYS_ONSURF_TYPE	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ONSURF_TYPE, 0, 1, newElems);

	/*	  Element id:	3954 : PRO_E_CSYS_DIM_CONSTRS	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_DIM_CONSTRS, 1, newElems);

	/*	  Element id:	2137 : PRO_E_CSYS_ORIENTMOVES	*/
	localElem.CreateCompoundElem(PRO_E_CSYS_ORIENTMOVES, 1, newElems);

	/*	  Element id:	3054 : PRO_E_CSYS_NORMAL_TO_SCREEN	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_NORMAL_TO_SCREEN, 0, 1, newElems);

	/*	  Element id:	3050 : PRO_E_CSYS_ORIENT_BY_METHOD	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENT_BY_METHOD, 0, 1, newElems);

	/*	  Element id:	2142 : PRO_E_CSYS_ORIENTSELAXIS1_REF	*/
	localElem.CreateSelectionElem(PRO_E_CSYS_ORIENTSELAXIS1_REF, 1, Model, 1, 2, newElems);

	/*	  Element id:	3167 : PRO_E_CSYS_ORIENTSELAXIS1_REF_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS1_REF_OPT, 0, 1, newElems);

	/*	  Element id:	2143 : PRO_E_CSYS_ORIENTSELAXIS1_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS1_OPT, 0, 1, newElems);

	/*	  Element id:	3052 : PRO_E_CSYS_ORIENTSELAXIS1_FLIP	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS1_FLIP, 0, 1, newElems);

	/*	  Element id:	2144 : PRO_E_CSYS_ORIENTSELAXIS2_REF	*/
	localElem.CreateSelectionElem(PRO_E_CSYS_ORIENTSELAXIS2_REF, 1, Model, 1, 4, newElems);

	/*	  Element id:	3168 : PRO_E_CSYS_ORIENTSELAXIS2_REF_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS2_REF_OPT, 0, 1, newElems);

	/*	  Element id:	2145 : PRO_E_CSYS_ORIENTSELAXIS2_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS2_OPT, 1, 1, newElems);

	/*	  Element id:	3053 : PRO_E_CSYS_ORIENTSELAXIS2_FLIP	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS2_FLIP, 0, 1, newElems);

	/*	  Element id:	4123 : PRO_E_CSYS_ORIENTSELAXIS2_ROT_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_ORIENTSELAXIS2_ROT_OPT, 0, 1, newElems);

	/*	  Element id:	4124 : PRO_E_CSYS_ORIENTSELAXIS2_ROT	*/
	localElem.CreateDoubleElem(PRO_E_CSYS_ORIENTSELAXIS2_ROT, 0, 1, newElems);

	/*	  Element id:	3051 : PRO_E_CSYS_TYPE_MECH	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_TYPE_MECH, 0, 1, newElems);

	/*	  Element id:	3932 : PRO_E_CSYS_FOLLOW_SRF_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_FOLLOW_SRF_OPT, 0, 1, newElems);

	/*	  Element id:	6133 : PRO_E_CSYS_NAME_DISPLAY_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_NAME_DISPLAY_OPT, 1, 1, newElems);

	/*	  Element id:	6140 : PRO_E_CSYS_DISPLAY_ZOOM_DEP_OPT	*/
	localElem.CreateIntegerElem(PRO_E_CSYS_DISPLAY_ZOOM_DEP_OPT, 0, 1, newElems);

	/*	  Element id:	6139 : PRO_E_CSYS_AXIS_LENGTH	*/
	localElem.CreateDoubleElem(PRO_E_CSYS_AXIS_LENGTH, 0, 1, newElems);


	return (newElems);
}

 

Thanks to everyone who participate in helping me out!

 

Regards

Daniel

View solution in original post

Announcements