cancel
Showing results for 
Search instead for 
Did you mean: 

How to instantiate UDF using KF and supply profile for revolve

Phenom
Phenom

I've defined a UDF that uses a revolve feature to generate some required geometry. I can instantiate this interactively fine, selecting 4 body edges for the new revolve profile.

But I can't work out how to instantiate this using KF. The ug_udfs class talks about using ug_section and ug_collector classes, but I'm struggling to understand how to use these.

After instantiating interactively I've adopted the UDF into KF and the resulting definition looks like this:

 

(Child) TangentialRevolvedFace: {
  Class, ug_udfs,
  Name, "TangentialRevolvedFace",
  Library, "No Library",
  Definition_File, "",
  Parameters, {},
  referenceFrame, FrameXY(Point_(0,0,0,worldFrame());Vector_(1,0,0,worldFrame());Vector_(0,1,0,worldFrame())),
  References, {
  	ug_refObject("TANGENTIAL_POSITION_CSYS:R-1820-6",""),
  	ug_refObject("Datum Axis:R-1807-6",""),
  	ug_refObject("Point:R-1811-6",""),
  	ug_refObject("Collector:R-3033-7",""),
  	ug_refObject("Section:R-3043-7","")
  },
  Initial_Mapping, {},
  targetLayer, 0,
  Suppress?, FALSE
};

Its the last 2 references I'm having problems with. I think what I'm supposed to do is create an instance of the ug_collector and ug_section classes and pass them in instead of the ug_refObject("Collector:R-3033-7","") and ug_refObject("Section:R-3043-7","")

 

Anyone got experience using these to supply a profile for a revolve feature?

 

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5
1 REPLY

Re: How to instantiate UDF using KF and supply profile for revolve

Phenom
Phenom

Finally managed to get this working. Below is the code I cobbled together manually in the Interactive Class Editor (ICE):

(Any Modifiable) l1: ug_refObject("Edge:C-48-6",""); 
(Any Modifiable) l2: ug_refObject("Edge:C-44-6",""); 
(Any Modifiable) l3: ug_refObject("Edge:C-52-6",""); 
(Any Modifiable) l4: ug_refObject("Edge:C-45-6",""); 
(Any Modifiable) dp: ug_refObject("Datum Plane:R-1801-6",""); 

(Child) section: {
	Class, ug_section,
	Chain_Rules, {Single_Edges, l1:, l2:, l3:, l4:},
};

(Child) collector: {
	Class, ug_collector,
	Rules, {Single_Faces, dp:},
};

(Child) TRF: {
  Class, ug_udfs,
  Name, "TangentialRevolvedFace",
  Library, "No Library",
  References, {
  	ug_refObject("TANGENTIAL_POSITION_CSYS:R-1820-6",""),
  	ug_refObject("Datum Axis:R-1807-6",""),
  	ug_refObject("Point:R-1811-6",""),
  	collector:,
  	section:,
  	ug_refObject("Datum Plane:C-10-6","")
  }
};

Once this worked I could then get it working in my Java code. To do this I create dynamic rules using the RuleManager:

RuleManager.createDynamicRule("root:", "section", "Child", sectionString, null);
RuleManager.createDynamicRule("root:", "collector", "Child", collectorString, null);
RuleManager.createDynamicRule("root:", "TRF", "Child", trfString, null);

RuleManager.doKfUpdate();

The sectionString, collectorString and trfString above consists of just the code between the braces from the first listing. For instance the sectionString looks like this:

{
	Class, ug_section,
	Chain_Rules, {Single_Edges, l1:, l2:, l3:, l4:},
};

The key here (and what tripped me up to start with) is that you MUST create the section and collector instances and the ug_udfs instance all at the same time before doing a KF Update. To start with I created the section and collector and did a KF Update after each and this seems to be A REALLY BAD THING (NX session and/or part gets corrupt). But finally I found a note in the ug_section and ug_collector KF classes that states:

The instantiation of this class can be referenced by those features that can
accept ug_section as its input. It can only be referenced by a single feature
right now. If it is used by multiple features, a checking error would occur.

Please avoid creating a section in KF without a feature using it immediately
because it can be in a wrong state for features.

So now I have it working and my revolve gets updated properly (using the section) and a trim body in the udf also updates OK (using the collector) Man Very Happy

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5