Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hi,
I'm not an expert in JAVA, but I try to understand the examples of the jlink-doc in Pro/E Wildfire 4. So I made some menu-modifications and got a script to modify some config-options working.
Now I try to put a drawing-symbol on the drawing. There ist an example in folder proE/jlink/jlink_appls/jlinkexamples: pfcDrawingExamples.java with the function: placeInst()
/*====================================================================*\
FUNCTION : placeSymInst()
PURPOSE : Place a CG symbol with no leaders at a specified location
\*====================================================================*/
public static void placeInst() throws com.ptc.cipjava.jxthrowable
{
/*--------------------------------------------------------------------*\
Get the current drawing
\*--------------------------------------------------------------------*/
Session session = pfcGlobal.GetProESession ();
Model model = session.GetCurrentModel();
if (model.GetType() != ModelType.MDL_DRAWING)
throw new RuntimeException ("Current model is not a drawing");
Drawing drawing = (Drawing) model;
/*--------------------------------------------------------------------*\
Retrieve the symbol definition from the system
\*--------------------------------------------------------------------*/
DetailSymbolDefItem symDef =
drawing.RetrieveSymbolDefinition ("CG", null, null, null); //<-- ErrorObject on second run!
/*--------------------------------------------------------------------*\
Select the locations for the symbol
\*--------------------------------------------------------------------*/
boolean stop = false;
Point3Ds points = Point3Ds.create ();
while (!stop)
{
MouseStatus mouse = session.UIGetNextMousePick (null);
if (mouse.GetSelectedButton() ==
MouseButton.MOUSE_BTN_LEFT)
{
points.insert (0, mouse.GetPosition());
}
else
stop = true;
}
/*--------------------------------------------------------------------*\
Allocate the symbol instance decription
\*--------------------------------------------------------------------*/
DetailSymbolInstInstructions instrs =
pfcDetail.DetailSymbolInstInstructions_Create (symDef);
for (int i = 0; i < points.getarraysize(); i++)
{
/*--------------------------------------------------------------------*\
Set the location of the note text
\*--------------------------------------------------------------------*/
FreeAttachment position =
pfcDetail.FreeAttachment_Create (points.get (i));
/*--------------------------------------------------------------------*\
Set the attachment structure
\*--------------------------------------------------------------------*/
DetailLeaders allAttachments =
pfcDetail.DetailLeaders_Create ();
allAttachments.SetItemAttachment (position);
instrs.SetInstAttachment (allAttachments);
/*--------------------------------------------------------------------*\
Create and display the symbol
\*--------------------------------------------------------------------*/
DetailSymbolInstItem symInst =
(DetailSymbolInstItem) drawing.CreateDetailItem (instrs);
symInst.Show();
}
}
I modified the script to get a symbol out of the symboldirectory and it works - but only once! I think, because the symbol is in the drawing yet. On the second run of the script with the same drawing there ist the following exception with RetrieveSymbolDefinition: com.ptc.pfc.Implementation.pfcExceptions$XToolkitFound
I have tried to modify the errorline to
DetailSymbolDefItem symDef =
drawing.RetrieveSymbolDefinition ("CG", null, null, true);
but when eclipse says
The method RetrieveSymbolDefinition(String, String, Integer, Boolean) in the type DetailItemOwner is not applicable for the arguments (String, String, null, boolean)
Has anybody an idea to get the script working again and again?
Thanks.
Andreas Vogt
Hi,
thank you for your support. But it don't work, because the DetailItem has no name! I think it should work with DetailSymbolDefItem DetailSymbolDefInstructions and GetInstructions - but I don't now how...
cu
Andreas Vogt
hi,
the DetailItems-List write down in an HTML-Sheet looks like this:
<h2>item.GetName() null</h2>
Index 0 item.GetId() 0 item.getClass().getSimpleName(); DetailSymbolDefItem
<h2>item.GetName() null</h2>
Index 1 item.GetId() 0 item.getClass().getSimpleName(); DetailSymbolInstItem
How can i get touch to the DetailSymbolDefItem with the item-list?
Andreas
hi again,
that's it! 🙂 Great, thank you!
With dsdi.GetInstructions().GetName() you get the Name of the symbol.
cu
Andreas