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

Generating a model with Java OTK_model tree

SOLVED

Re: Generating a model with Java OTK_model tree

Thanks, all worked well!

I shortened the code in from an example:

public void OnCommand()
	{
		try {
	         Session session = pfcSession.GetCurrentSession ();
	         
	         SelectionOptions dirSelopts = pfcSelect.SelectionOptions_Create("feature, datum, csys");
	         dirSelopts.SetMaxNumSels(new Integer(1));
	         Selections dirSels = session.Select(dirSelopts, null);
	                 	 
	         ModelItem item = dirSels.get(0).GetSelItem();
	         Feature feat = (Feature)item;
	         WFeature wfeat = (WFeature) feat;
	         ElementTree elementtree = wfeat.GetElementTree(null, FeatureElemTreeExtractOptions.FEAT_EXTRACT_NO_OPTS);
             elementtree.WriteElementTreeToFile(ElementTreeFormat.ELEMTREE_XML, "feat.xml");
	      
	      } catch (Throwable e) {
	         e.printStackTrace();
	         System.out.println("????: " + e);
	        }
	}
}

But now I have another question.
I create a plane using FET. I make a plane with an offset from the example:Снимок.PNG

The PRO_E_DTMPLN_CONSTR_REF parameter was created as follows:

//PRO_E_DTMPLN_CONSTR_REF
Element elem_3_1 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_DTMPLN_CONSTR_REF,pfcArgument.CreateSelectionArgValue(dirSels.get(0)),3);
elements.append(elem_3_1);

That is, I select the reference plane interactively. But I need to set the reference plane existing in the model from the code.

Do you know how to refer to the plane existing in the model?

Thanks in advance!

 

Best Regards!

Re: Generating a model with Java OTK_model tree

Hi,

you must to create a Selection with ModelItem (plane) by your self.

Take a look "Programmatic Selection"

Re: Generating a model with Java OTK_model tree

Thanks for the advice!
I wrote this code:

Session session = pfcSession.GetCurrentSession ();
WSession ses = (WSession)session;
Model model = ses.GetCurrentModel();
Solid solid = (Solid)model;
ModelItems items = solid.ListItems(ModelItemType.ITEM_SURFACE);
Surface plane = (Surface)items.get(0);
Selection dirSels1 =  pfcSelect.CreateModelItemSelection(plane, null);

//PRO_E_DTMPLN_CONSTR_REF
Element elem_3_1 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_DTMPLN_CONSTR_REF,pfcArgument.CreateSelectionArgValue(dirSels1),3);
elements.append(elem_3_1);

It works. But only with those planes that are associated with a solid, as written in the manual:

Interface ModelItemOwner/ListItems/Parameters (Note that only those surfaces associated with solid geometry are included in the list of model items when you specify ITEM_SURFACE or null as the Type . Surfaces of Creo Parametric Surface features and Quilts are not included). 

But I need to get access to any surfaces, and not just those that are associated with solids.

Do you know how to fix it?

Excuse me for asking so many questions, I started working with the API not so long ago.

Thanks in advance.

 

Best Regards!

 

 

Re: Generating a model with Java OTK_model tree


@VladiSlav wrote:

 

But I need to get access to any surfaces, and not just those that are associated with solids.


I not sure but, I think, if you interesting to get surfaces from separate surface (feature created as surface), than need to firs get item of this feature.

ModelItems items = solid.ListItems(ModelItemType.ITEM_FEATURE);

Then take a look at chapter "Geometry Evaluation"

 

ps: "To obtain a list of the quilt features with their component datum surfaces, specify ITEM_QUILT."

Re: Generating a model with Java OTK_model tree

Thanks, that helped a lot!
Now I'm dealing with extrusion.
I start, the element is created, but broken, it does not have a section.
Checking the code, I found on which line it throws an error.
My code is:

public class Extrude extends DefaultUICommandActionListener {
	
	static int i = 0;
	public Extrude()
	{
	}

	public void OnCommand() throws jxthrowable
	{				
		++i;
		if (i == 1)
			createPart();
		else if (i>1)
			DTM();	
    }
	  
	public void createPart() {
    	try
		{
			Session curSession = pfcSession.GetCurrentSessionWithCompatibility(CreoCompatibility.C4Compatible);
			String modelLocation = ".........";
			String model_name = "........";
			ModelDescriptor desc = null;
			curSession.GetCurrentWindow().Activate();
			desc = pfcModel.ModelDescriptor_CreateFromFileName(model_name);
			desc.SetPath (modelLocation);			
			Model template = curSession.RetrieveModelWithOpts(desc, pfcSession.RetrieveModelOptions_Create());
		    Model newPart = template.CopyAndRetrieve("Test", null);
		    Window newWindow = curSession.CreateModelWindow(newPart); 
		    newPart.Display(); 
		    curSession.SetCurrentWindow(newWindow); 
		    newWindow.Activate();
		    template.Erase();
		} catch (Exception e)
	    	{
				System.out.println("1: " + e);
	    	}
		
	}
	
	public void DTM()  throws jxthrowable {
		try {
			
			int quan;
			String name;
			String allname = "";
			
			Session session = pfcSession.GetCurrentSession ();
			SelectionOptions dirSelopts = pfcSelect.SelectionOptions_Create("datum,surface,curve,csys,edge,axis");
			dirSelopts.SetMaxNumSels(new Integer(1));				
			Selections dirSels = session.Select(dirSelopts, null);
			
			//------------------------------------------------------------ 
			WSession ses = (WSession)session;
			Model model = ses.GetCurrentModel();
			Solid solid = (Solid)model;
			ModelItems items = solid.ListItems(ModelItemType.ITEM_FEATURE);

			for (int j = 0; j < items.getarraysize(); j++) {
				name = ((Feature)items.get(j)).GetName();
				quan = ((Feature)items.get(j)).ListSubItems(ModelItemType.ITEM_SURFACE).getarraysize();
				allname = allname + name + ": " + quan + "\n";
				
			}			
			
			Surface plane = (Surface)((Feature)items.get(3)).ListSubItems(ModelItemType.ITEM_SURFACE).get(0);
			Selection dirSels1 =  pfcSelect.CreateModelItemSelection(plane, null);
			//------------------------------------------------------------
			
			Elements elements = Elements.create();
			
			//PRO_E_FEATURE_TREE
			Element elem_0_0 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_FEATURE_TREE,null,0);
		    elements.append(elem_0_0);
		    
		    //PRO_E_STD_FEATURE_NAME
		    Element elem_1_0 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_FEATURE_NAME, pfcArgument.CreateStringArgValue("My_extrude"),1);
		    elements.append(elem_1_0);
		    
		    //PRO_E_FEATURE_TYPE
		    Element elem_1_1 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_FEATURE_TYPE, pfcArgument.CreateIntArgValue(0),1);
		    elements.append(elem_1_1);
		    
		    //PRO_E_FEATURE_FORM
		    Element elem_1_2 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_FEATURE_FORM, pfcArgument.CreateIntArgValue(1),1);
		    elements.append(elem_1_2);
		    
		    //PRO_E_FEAT_FORM_IS_THIN
		    Element elem_1_3 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_FEAT_FORM_IS_THIN, pfcArgument.CreateIntArgValue(0),1);
		    elements.append(elem_1_3);
		    
		    //PRO_E_EXT_SURF_CUT_SOLID_TYPE 
		    Element elem_1_4 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_EXT_SURF_CUT_SOLID_TYPE, pfcArgument.CreateIntArgValue(917),1);
		    elements.append(elem_1_4);
		    
		    //PRO_E_REMOVE_MATERIAL
		    Element elem_1_5 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_REMOVE_MATERIAL, pfcArgument.CreateIntArgValue(-1),1);
		    elements.append(elem_1_5);
		    
		    //PRO_E_STD_EXT_DEPTH
		    Element elem_1_6 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_EXT_DEPTH, null,1);
		    elements.append(elem_1_6);
		    
		    //PRO_E_EXT_DEPTH_FROM
		    Element elem_2_0 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_EXT_DEPTH_FROM, null,2);
		    elements.append(elem_2_0);
		    
		    //PRO_E_EXT_DEPTH_FROM_TYPE
		    Element elem_3_0 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_EXT_DEPTH_FROM_TYPE, pfcArgument.CreateIntArgValue(128),3);
		    elements.append(elem_3_0);
		    
		    //PRO_E_EXT_DEPTH_FROM_VALUE
		    Element elem_3_1 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_EXT_DEPTH_FROM_VALUE, pfcArgument.CreateDoubleArgValue(100),3);
		    elements.append(elem_3_1);
		    
		    //PRO_E_EXT_DEPTH_TO
		    Element elem_2_1 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_EXT_DEPTH_TO, null,2);
		    elements.append(elem_2_1);
		    
		    //PRO_E_EXT_DEPTH_TO_TYPE
		    Element elem_3_2 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_EXT_DEPTH_TO_TYPE, pfcArgument.CreateIntArgValue(268435456),3);
		    elements.append(elem_3_2);
		    
		    //PRO_E_STD_SECTION
		    Element elem_1_7 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_SECTION, null,1);
		    elements.append(elem_1_7);
		    
		    //PRO_E_STD_SEC_SETUP_PLANE
		    Element elem_2_2 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_SEC_SETUP_PLANE, null,2);
		    elements.append(elem_2_2);
		    
		    //PRO_E_STD_SEC_PLANE
		    Element elem_3_3 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_SEC_PLANE, pfcArgument.CreateSelectionArgValue(dirSels1),3);
		    elements.append(elem_3_3);
		    
		    //PRO_E_STD_SEC_PLANE_VIEW_DIR
		    Element elem_3_4 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_SEC_PLANE_VIEW_DIR, pfcArgument.CreateIntArgValue(1),3);
		    elements.append(elem_3_4);
		    
		    //PRO_E_STD_SEC_PLANE_ORIENT_DIR
		    Element elem_3_5 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_SEC_PLANE_ORIENT_DIR, pfcArgument.CreateIntArgValue(1),3);
		    elements.append(elem_3_5);
		    		   
		    WSession wSession = (WSession)session;
		    ElementTree	elemTree = wSession.CreateElementTree(elements);		    
		    FeatCreateOptions featOpts = FeatCreateOptions.create();
		    featOpts.append(FeatCreateOption.FEAT_CR_INCOMPLETE_FEAT);
		    WRegenInstructions regenInstr = wfcSolidInstructions.WRegenInstructions_Create();		    
		    Model currModel = session.GetCurrentModel();
		    WSolid currSolid = (WSolid)currModel;		    
		    WFeature extrudeFeat = currSolid.WCreateFeature(elemTree,featOpts,regenInstr);		    
		    elemTree = extrudeFeat.GetElementTree(null,FeatureElemTreeExtractOptions.FEAT_EXTRACT_NO_OPTS);		    
		    Element sketchElem = GetSketcherElement(elemTree);	    		    
		    SpecialValue sketchSpvalue = sketchElem.GetSpecialValueElem();
		    Section sketch = sketchSpvalue.GetSectionValue();         //!!!!Error is here!!!!		    		    
		    sketch.SetIntentManagerMode(true);
		    Point2D center = wfcSession.CreatePoint2D(0.00,0.00);		    		    		    
		    SectionEntityCircle circle = wfcSection.SectionEntityCircle_Create(center,40.00);		    		    		    
		    SectionEntity entity = (SectionEntity)circle;		    		    		    		    
		    sketch.AddEntity(entity);		    
		    sketch.SetIntentManagerMode(false);		    
		    sketchSpvalue.SetSectionValue(sketch);
		    sketchElem.SetSpecialValueElem(sketchSpvalue);		    
		    featOpts.insert(0, FeatCreateOption.FEAT_CR_NO_OPTS);		    	   
		    extrudeFeat.RedefineFeature(null,elemTree,featOpts,regenInstr);		    		    
		}	
		catch (Exception e)
	    	{
			System.out.println("1: " + e);
			Session curSession = pfcSession.GetCurrentSessionWithCompatibility(CreoCompatibility.C4Compatible);
			curSession.UIShowMessageDialog("Error!", null);
	    	}
	}				
	static Element GetSketcherElement(ElementTree elemTree)
    {
	/*
	  Get PRO_E_SKECTHER element using wfcElementPath_ptr	  
	  NOTE: To get an element with level greater than 1 you must
	  define element path with respect to PRO_E_FEATURE_TREE 	  
	*/	
	try
	    {		
		ElemPathItems sketchItems =  ElemPathItems.create();
		ElemPathItem sketchItem0 =  wfcElementTree.ElemPathItem_Create(ElemPathItemType.ELEM_PATH_ITEM_TYPE_ID,wfcElemIds.PRO_E_STD_SECTION);
		sketchItems.append(sketchItem0);
		ElemPathItem sketchItem1 =  wfcElementTree.ElemPathItem_Create(ElemPathItemType.ELEM_PATH_ITEM_TYPE_ID,wfcElemIds.PRO_E_SKETCHER);
		sketchItems.append(sketchItem1);		
		ElementPath sketchPath = wfcElementTree.ElementPath_Create(sketchItems);		
		Element element = elemTree.GetElement(sketchPath);	
		return(element); 	
	    }
	catch (Exception e)
    {
	System.out.println("1: " + e);
    }	
	return null;
    }	
}

I created an xml file for the failed element. I attach it.

You do not know what is wrong?
Thanks in advance!
Regards!

Re: Generating a model with Java OTK_model tree

Create feature using element tree it is not easy task. My advice is manually create Extrusion feature in Creo. Than export this feature to XML and compare it with yours XML. Maybe you miss something.

Another way is edit exported XML to meet your task and import it for creating new feature.

And do you really want to create a whole model using element tree? I think this is extremely hard. Maybe you can use "template" model. Then just change desired dimensions. Or use UDF (user defined feature).

 

PS: several examples of extrusion feature in C toolkit  ...\Common Files\protoolkit\protk_appls\pt_userguide\ptu_featcreat

Re: Generating a model with Java OTK_model tree

Thanks!
I have already created XML for extraction obtained in Creo. From the comparison, I concluded that my PRO_E_SKETCHER is not filled, as the error shows, as well as the created element in the model tree (there is no section there).
Now I just deal with the tree of elements, looking for possible options.
I do not want to create a model from the template, because the logic and various options make the model heavy. In my opinion, the generation will allow transferring all calculations to the program code, which will facilitate the model.
I did not know about UDF functions, thanks.
I saw examples from protoolkit, on them I also tried to make the code.

 

Best Regards!

Highlighted

Re: Generating a model with Java OTK_model tree

I found a mistake.
Everything works now.
My code is:

public Extrude()
	{
	}
public void OnCommand() throws jxthrowable
	{
	Session session = pfcSession.GetCurrentSession ();
	Model currModel = session.GetCurrentModel();
	if(currModel == null)
		createPart();
	else
		modelBuild();
	}  
public void createPart() throws jxthrowable {
    	try
	{
	Session curSession = pfcSession.GetCurrentSessionWithCompatibility(CreoCompatibility.C4Compatible);
	String modelLocation = "......";
	String model_name = ".......";
	ModelDescriptor desc = null;
	curSession.GetCurrentWindow().Activate();
	desc = pfcModel.ModelDescriptor_CreateFromFileName(model_name);
	desc.SetPath (modelLocation);
	Model template = curSession.RetrieveModelWithOpts(desc, pfcSession.RetrieveModelOptions_Create());
	Model newPart = template.CopyAndRetrieve("Test", null);
	Window newWindow = curSession.CreateModelWindow(newPart); 
	newPart.Display(); 
	curSession.SetCurrentWindow(newWindow); 
	newWindow.Activate();
	template.Erase();
	} catch (Exception e)
	{
	System.out.println("1: " + e);
	Session session = pfcSession.GetCurrentSessionWithCompatibility(CreoCompatibility.C4Compatible);
	Model currModel = session.GetModel("......", ModelType.MDL_PART);
	currModel.Erase();
	}	
	}
public void modelBuild()  throws jxthrowable {
	try {
	int quan;
	String name;
	String allname = "";
	Session session = pfcSession.GetCurrentSession ();
	WSession ses = (WSession)session;
	Model model = ses.GetCurrentModel();
	Solid solid = (Solid)model;
	ModelItems items = solid.ListItems(ModelItemType.ITEM_FEATURE);
		for (int j = 0; j < items.getarraysize(); j++) {
			name = ((Feature)items.get(j)).GetName();
			quan = ((Feature)items.get(j)).ListSubItems(ModelItemType.ITEM_SURFACE).getarraysize();
			allname = allname + name + ": " + quan + "\n";				
		}			
	//session.UIShowMessageDialog(allname, null);
	Surface plane = (Surface)((Feature)items.get(3)).ListSubItems(ModelItemType.ITEM_SURFACE).get(0);
	Surface plane1 = (Surface)((Feature)items.get(2)).ListSubItems(ModelItemType.ITEM_SURFACE).get(0);
	Selection dirSels1 =  pfcSelect.CreateModelItemSelection(plane, null);
	Selection dirSels2 =  pfcSelect.CreateModelItemSelection(plane1, null);	
	
	Elements elements = Elements.create();		
	//PRO_E_FEATURE_TREE
	Element elem_0_0 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_FEATURE_TREE,null,0);
	elements.append(elem_0_0);
	//PRO_E_STD_FEATURE_NAME
	Element elem_1_0 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_FEATURE_NAME, pfcArgument.CreateStringArgValue("My_extrude"),1);
	elements.append(elem_1_0); 
	//PRO_E_FEATURE_FORM
	Element elem_1_2 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_FEATURE_FORM, pfcArgument.CreateIntArgValue(1),1);
	elements.append(elem_1_2);
	//PRO_E_FEAT_FORM_IS_THIN
	Element elem_1_3 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_FEAT_FORM_IS_THIN, pfcArgument.CreateIntArgValue(0),1);
	elements.append(elem_1_3);
	//PRO_E_EXT_SURF_CUT_SOLID_TYPE 
	Element elem_1_4 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_EXT_SURF_CUT_SOLID_TYPE, pfcArgument.CreateIntArgValue(917),1);
	elements.append(elem_1_4);
	//PRO_E_REMOVE_MATERIAL
	Element elem_1_5 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_REMOVE_MATERIAL, pfcArgument.CreateIntArgValue(-1),1);
	elements.append(elem_1_5);
	//PRO_E_STD_EXT_DEPTH
	Element elem_1_6 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_EXT_DEPTH, null,1);
	elements.append(elem_1_6);
	//PRO_E_EXT_DEPTH_FROM
	Element elem_2_0 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_EXT_DEPTH_FROM, null,2);
	elements.append(elem_2_0);
	//PRO_E_EXT_DEPTH_FROM_TYPE
	Element elem_3_0 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_EXT_DEPTH_FROM_TYPE, pfcArgument.CreateIntArgValue(128),3);
	elements.append(elem_3_0);
	//PRO_E_EXT_DEPTH_FROM_VALUE
	Element elem_3_1 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_EXT_DEPTH_FROM_VALUE, pfcArgument.CreateDoubleArgValue(100),3);
	elements.append(elem_3_1);
	//PRO_E_EXT_DEPTH_TO
	Element elem_2_1 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_EXT_DEPTH_TO, null,2);
	elements.append(elem_2_1);
	//PRO_E_EXT_DEPTH_TO_TYPE
	Element elem_3_2 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_EXT_DEPTH_TO_TYPE, pfcArgument.CreateIntArgValue(268435456),3);
	elements.append(elem_3_2);
	//PRO_E_STD_SECTION
	Element elem_1_7 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_SECTION, null,1);
	elements.append(elem_1_7);
	//PRO_E_STD_SEC_SETUP_PLANE
	Element elem_2_2 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_SEC_SETUP_PLANE, null,2);
	elements.append(elem_2_2);
	//PRO_E_STD_SEC_PLANE
	Element elem_3_3 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_SEC_PLANE, pfcArgument.CreateSelectionArgValue(dirSels1),3);
	elements.append(elem_3_3);
	//PRO_E_STD_SEC_PLANE_VIEW_DIR
	Element elem_3_4 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_SEC_PLANE_VIEW_DIR, pfcArgument.CreateIntArgValue(1),3);
	elements.append(elem_3_4);
	//PRO_E_STD_SEC_PLANE_ORIENT_DIR
	Element elem_3_5 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_SEC_PLANE_ORIENT_DIR, pfcArgument.CreateIntArgValue(1),3);
	elements.append(elem_3_5);
	//PRO_E_STD_SEC_PLANE_ORIENT_REF
	Element elem_3_6 = wfcElementTree.Element_Create(wfcElemIds.PRO_E_STD_SEC_PLANE_ORIENT_REF, pfcArgument.CreateSelectionArgValue(dirSels2),3);
	elements.append(elem_3_6);  
		    		   
	WSession wSession = (WSession)session;
	ElementTree	elemTree = wSession.CreateElementTree(elements);
	FeatCreateOptions featOpts = FeatCreateOptions.create();
	featOpts.append(FeatCreateOption.FEAT_CR_INCOMPLETE_FEAT);
	WRegenInstructions regenInstr = wfcSolidInstructions.WRegenInstructions_Create();
	Model currModel = session.GetCurrentModel();
	WSolid currSolid = (WSolid)currModel;
	WFeature extrudeFeat = currSolid.WCreateFeature(elemTree,featOpts,regenInstr);
	elemTree = extrudeFeat.GetElementTree(null,FeatureElemTreeExtractOptions.FEAT_EXTRACT_NO_OPTS);
	Element sketchElem = GetSketcherElement(elemTree);								
	SpecialValue sketchSpvalue = sketchElem.GetSpecialValueElem(); 					
	Section sketch = sketchSpvalue.GetSectionValue();         								    
	sketch.SetIntentManagerMode(true);
	Point2D center = wfcSession.CreatePoint2D(0.00,0.00);		    		    
	SectionEntityCircle circle = wfcSection.SectionEntityCircle_Create(center,300.00);		    		    
	SectionEntity entity = (SectionEntity)circle;		    		    		    
	sketch.AddEntity(entity);
	circle = wfcSection.SectionEntityCircle_Create(center,20.00);
	entity = (SectionEntity)circle;
	sketch.AddEntity(entity);
	sketch.SetIntentManagerMode(false);
	sketchSpvalue.SetSectionValue(sketch);
	sketchElem.SetSpecialValueElem(sketchSpvalue);
	featOpts.insert(0, FeatCreateOption.FEAT_CR_NO_OPTS);
	extrudeFeat.RedefineFeature(null,elemTree,featOpts,regenInstr);
	}
	catch (Exception e)
	{
	System.out.println("1: " + e);
	Session curSession = pfcSession.GetCurrentSessionWithCompatibility(CreoCompatibility.C4Compatible);
	curSession.UIShowMessageDialog("Error!", null);
	}
	}
static Element GetSketcherElement(ElementTree elemTree)
    {	
	try
	{
	ElemPathItems sketchItems =  ElemPathItems.create();
	ElemPathItem sketchItem0 =  wfcElementTree.ElemPathItem_Create(ElemPathItemType.ELEM_PATH_ITEM_TYPE_ID,wfcElemIds.PRO_E_STD_SECTION);
	sketchItems.append(sketchItem0);
	ElemPathItem sketchItem1 =  wfcElementTree.ElemPathItem_Create(ElemPathItemType.ELEM_PATH_ITEM_TYPE_ID,wfcElemIds.PRO_E_SKETCHER);
	sketchItems.append(sketchItem1);	
	ElementPath sketchPath = wfcElementTree.ElementPath_Create(sketchItems);
	Element element = elemTree.GetElement(sketchPath);
	return(element); 
	}
	catch (Exception e)
	{
	System.out.println("1: " + e);	
	}	
	return null;
}

Thanks everyone!
I hope it will be useful!

 

View solution in original post

Announcements