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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

How to get the value of BOM balloon index/text available in the current drawing in creo2 (M130) using J-Link?

sekambaram
2-Explorer

How to get the value of BOM balloon index/text available in the current drawing in creo2 (M130) using J-Link?

Hello Friends,

How to get the value of BOM balloon index/text available in the current drawing in creo2 (M130) using J-Link?

Already searched the J-Link API BOM balloon option are not available.

3 REPLIES 3
James62
12-Amethyst
(To:sekambaram)

hi,

Turns out i was wrong about casting the bom balloon model item to a note. It's got little more difficult than that, try the following code.

Window currentWindow = session.GetCurrentWindow();

Model model = currentWindow.GetModel();

if (model.GetType() != ModelType.MDL_DRAWING) {

    throw new RuntimeException("Current model is not a drawing.");

}

Model2D drwModel = (Model2D) model;

// Get all symbols, the second argument here is the sheet number

DetailItems detailItems

    = drwModel.ListDetailItems(DetailType.DETAIL_SYM_INSTANCE, 1);

for (int i = 0; i < detailItems.getarraysize(); i++) {

    DetailItem detailItem = detailItems.get(i);

    // The GetName() method can be used to figure out if the

    // symbol is a bom balloon

    String detailItemName = detailItem.GetName();

    // Detail type displays number 3 for any symbol

    DetailType detailItemType = detailItem.GetDetailType();

    // Cast to symbol

    DetailSymbolInstItem symbolItem = (DetailSymbolInstItem) detailItem;

    // false is to get the actual text shown to the user

    DetailSymbolInstInstructions symInstructions

        = symbolItem.GetInstructions(false);

    DetailVariantTexts textValues = symInstructions.GetTextValues();

    // Get the first line of the text

    DetailVariantText textVal = textValues.get(0);

    // check if the symbol is a bom balloon

    if (detailItemName.contains("balloon")) {

        // Display message dialog box

        session.UIShowMessageDialog("Detail item name: "

            + detailItemName + "\n"

            + "Detail item type num: " + detailItemType.getValue() + "\n"

            + "Symbol text value: " + textVal.GetValue(), null);

    }

}

Hi,

Thanks for your reply, and i tried your code in my case it is not working it is not listing the DETAIL_SYM_INSTANCE type.

while i am using

  1. DetailItems detailItems = drwModel.ListDetailItems(DetailType.DETAIL_SYM_INSTANCE, 1);  

this line my detailItems.getarraysize() is "0" so, it is continue this flow.


So, I tried the following lines


               DetailItems dtlItems = dtlItemOwner.ListDetailItems(DetailType.DETAIL_NOTE, 1);

               String dtlTextString = null, drwViewName = null;

                for (int i = 0; i < dtlItems.getarraysize(); ++i)

               {

                   DetailNoteItem dtlNote = (DetailNoteItem) dtlItems.get(i);

                   DetailType dtype = dtlNote.GetDetailType();

                   DetailNoteInstructions noteInstrs = dtlNote.GetInstructions(false);

                  

                    // Check if the note has any leader which attaches to a drawing view.

                    Attachments noteLeaders = noteInstrs.GetLeader().GetLeaders();

                    // Get the note text strings.

                     DetailTextLines noteLines = noteInstrs.GetTextLines();

              

                    for (int j = 0; j < noteLines.getarraysize(); ++j)

                    {

                        DetailTexts dtlTexts = noteLines.get(j).GetTexts();

                       

                        for (int k = 0; k < dtlTexts.getarraysize(); ++k)

                        {

                            dtlTextString = dtlTexts.get(k).GetText();

                        }

                    }

                

             }


in this time i am getting all notes text available in the current drawing including BOM balloon notes and Normal notes. Now i am facing problem in filtering BOM balloons note text from all note text. If this is a correct flow means help on this, otherwise let me know other options are there.

James62
12-Amethyst
(To:sekambaram)

hi,

Ok, I see. When i switch to the default Simple Circle bom balloons type and double click on one of the balloons a Note Properties window pops up.

balloon_simple_circle.JPG

But when I switch to Custom type of bom balloons and use a symbol, which is what i use by default, then when i double click the balloon a totally different window shows up.

balloon_custom_symbol.JPG

Unless you know what text you are looking for inside of the bom balloons or a regex pattern at least then you can't really differentiate between notes and these default bom balloons. So, I'm not sure how to go about without switching to custom type of bom balloon right now.

You could possibly automate the switch to custom symbols and switch back operation. It'd require selection of each table, which is what you can do with J-Link with the following code.

Window currentWindow = session.GetCurrentWindow();

Model model = currentWindow.GetModel();

if (model.GetType() != ModelType.MDL_DRAWING) {

    throw new RuntimeException("Current model is not a drawing.");

}

Model2D drwModel = (Model2D) model;

Tables drwTables = drwModel.ListTables();

for (int i = 0; i < drwTables.getarraysize(); i++) {

    Table drwTable = drwTables.get(i);

    // add the table to a new selection

    Selection selection = pfcSelect.CreateModelItemSelection(drwTable, null); 

    // get the current selection buffer

    SelectionBuffer selBuffer = session.GetCurrentSelectionBuffer(); 

    // erase the current selection buffer

    selBuffer.Clear();

    // add the selection to a the selection buffer

    selBuffer.AddSelection(selection);

    // display a message dialog box

    session.UIShowMessageDialog("Selected table index: " + (i + 1), null);

    // erase the current selection buffer 

    selBuffer.Clear();

}

To change the type of the bom balloon record a couple of mapkeys and use RunMacro within the loop of the J-Link code above.

Announcements


Top Tags