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

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

jlink and Drawing Symbols

AndreasVogt
5-Regular Member

jlink and Drawing Symbols

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


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
6 REPLIES 6
bfrandsen
6-Contributor
(To:AndreasVogt)

Andreas,
when the symbol definition already is on the drawing you must find it as a
modelitem of type ITEM_DTL_SYM_DEFINITION.
Use something like:
drawing.GetItemByName(ModelItemType.ITEM_DTL_SYM_DEFINITION, "CG");

Good luck
Bjarne Frandsen



"Andreas Vogt" <a.vogt@ibb-konstruktion.de>
16-04-2009 11:19
Please respond to
"Andreas Vogt" <a.vogt@ibb-konstruktion.de>


To
-
cc

Subject
[proecus] - jlink and Drawing Symbols






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
-----End Original Message-----
AndreasVogt
5-Regular Member
(To:AndreasVogt)

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

bfrandsen
6-Contributor
(To:AndreasVogt)

Andreas,
try drawing.ListItems(ModelItemType.ITEM_DTL_SYM_DEFINITION);
/Bjarne



"Andreas Vogt" <a.vogt@ibb-konstruktion.de>
17-04-2009 10:17
Please respond to
"Andreas Vogt" <a.vogt@ibb-konstruktion.de>


To
-
cc

Subject
[proecus] - RE: jlink and Drawing Symbols






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
-----End Original Message-----
AndreasVogt
5-Regular Member
(To:AndreasVogt)

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

bfrandsen
6-Contributor
(To:AndreasVogt)

You need to cast the ModelItem to DetailSymbolDefItem:
DetailSymbolDefItem dsdi = (DetailSymbolDefItem)item;

/Bjarne



"Andreas Vogt" <a.vogt@ibb-konstruktion.de>
17-04-2009 11:28
Please respond to
"Andreas Vogt" <a.vogt@ibb-konstruktion.de>


To
-
cc

Subject
[proecus] - RE: jlink and Drawing Symbols






hi,
the DetailItems-List write down in an HTML-Sheet looks like this:
item.GetName() null
Index 0 item.GetId() 0 item.getClass().getSimpleName();
DetailSymbolDefItem

item.GetName() null
Index 1 item.GetId() 0 item.getClass().getSimpleName();
DetailSymbolInstItem
How can i get touch to the DetailSymbolDefItem with the item-list?
Andreas
-----End Original Message-----
AndreasVogt
5-Regular Member
(To:AndreasVogt)

hi again,

that's it! 🙂 Great, thank you!

With dsdi.GetInstructions().GetName() you get the Name of the symbol.

cu

Andreas

Top Tags