Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
1. example pfcUDFCreateExamples.html comes with Creo at "...\Common Files\M230\weblink\weblinkexamples"
2. It can work
but needs a click to specify the csys to place the UDF <--- problem !!! csys is given whey still needs a click?
find the source code and necessary .prt .gph to see the symptom.
Thank you very much!!!
Solved! Go to Solution.
• | PromptForReference—The prompt defined for this reference when the UDF was originally set up. It indicates which reference this structure is providing. If you get the prompt wrong, pfcSolid.CreateUDFGroup() will not recognize it and prompts the user for the reference in the usual way. |
I don't understand what does it mean. Sounds like the 'prompt' is a password the caller must provide it correctly or the given reference will be ignored and thus the function waits for a mouse click instead. That's a mistake-proof I guess.
• | PromptForReference—The prompt defined for this reference when the UDF was originally set up. It indicates which reference this structure is providing. If you get the prompt wrong, pfcSolid.CreateUDFGroup() will not recognize it and prompts the user for the reference in the usual way. |
I don't understand what does it mean. Sounds like the 'prompt' is a password the caller must provide it correctly or the given reference will be ignored and thus the function waits for a mouse click instead. That's a mistake-proof I guess.
package net.murphy.UDF;
import com.ptc.cipjava.jxthrowable;
import com.ptc.pfc.pfcModel.Model;
import com.ptc.pfc.pfcModel.ModelType;
import com.ptc.pfc.pfcSelect.Selection;
import com.ptc.pfc.pfcSession.Session;
import com.ptc.pfc.pfcSolid.Solid;
import com.ptc.pfc.pfcUDFCreate.UDFCustomCreateInstructions;
import com.ptc.pfc.pfcUDFCreate.UDFOrientation;
import com.ptc.pfc.pfcUDFCreate.UDFOrientations;
import com.ptc.pfc.pfcUDFCreate.UDFReference;
import com.ptc.pfc.pfcUDFCreate.UDFReferences;
import com.ptc.pfc.pfcUDFCreate.UDFVariantDimension;
import com.ptc.pfc.pfcUDFCreate.UDFVariantValues;
import com.ptc.pfc.pfcUDFCreate.pfcUDFCreate;
import net.murphy.MurphyUI.MurphyUIManager;
import net.murphy.Select.MurphySelector;
public class MurphyBoss {
private static MurphyUIManager mManager;
private static MurphySelector selector;
private static void init(Session session)throws jxthrowable{
if(mManager==null) mManager=new MurphyUIManager(session,"Jboss.txt",null,null);
if(selector==null ) selector=new MurphySelector(session);
}
public static void placeOneBoss(Session s)throws jxthrowable{
Model model=s.GetCurrentModel();
if(model==null || model.GetType()!=ModelType.MDL_PART) return;
init(s);
UDFCustomCreateInstructions bossInstr=pfcUDFCreate.UDFCustomCreateInstructions_Create("boss");
UDFReferences refs=UDFReferences.create();
mManager.display("SelectSketchPlane",null);
Selection plane_sel=selector.MakeSelection("datum,surface");
UDFReference plane_ref=pfcUDFCreate.UDFReference_Create("sketch_plane", plane_sel);
refs.set(0, plane_ref);
mManager.display("SelectHorizReference", null);
Selection horiz_sel=selector.MakeSelection("datum,surface");
UDFReference horiz_ref=pfcUDFCreate.UDFReference_Create("horiz_ref", horiz_sel);
refs.set(1, horiz_ref);
mManager.display("SelectLeftReference", null);
Selection left_sel=selector.MakeSelection("datum,surface");
UDFReference left_ref=pfcUDFCreate.UDFReference_Create("left_ref", left_sel);
refs.set(2, left_ref);
bossInstr.SetReferences(refs);
UDFOrientations orients=UDFOrientations.create();
orients.insert(0,UDFOrientation.UDFORIENT_INTERACTIVE);
orients.insert(1, UDFOrientation.UDFORIENT_INTERACTIVE);
bossInstr.SetOrientations(orients);
UDFVariantValues vals=UDFVariantValues.create();
mManager.display("InputXPos", null);
double xpos=s.UIReadRealMessage(6.0, 164.0);
UDFVariantDimension xpos_val=pfcUDFCreate.UDFVariantDimension_Create("xpos", xpos);
vals.insert(0, xpos_val);
mManager.display("InputYPos", null);
double ypos=s.UIReadRealMessage(-35.0, 35.0);
UDFVariantDimension ypos_val=pfcUDFCreate.UDFVariantDimension_Create("ypos", ypos);
vals.insert(1, ypos_val);
UDFVariantDimension offset_val=pfcUDFCreate.UDFVariantDimension_Create("offset", 3.0);
vals.insert(2, offset_val);
bossInstr.SetVariantValues(vals);
Solid solid=(Solid)model;
solid.CreateUDFGroup(bossInstr);//
solid.Regenerate(null);
s.GetCurrentWindow().Repaint();
}
}
This is the method for Jlink while you create UDF, all you need to do is to constructure the compact class (this kind of class just contains the dataobject for the other static mehod especially the static method to create some class )UDFGroupCreateInstructions to be passed to the method
CreateUDFGroup |
(UDFGroupCreateInstructions Instructions)
|
weblink is the same as this! however,if you still need the method for weblink ,pls send me a message