18 December 2018 1 1K Report

I have a model with a named selection called "Bolts". I would like to select from that named selection only the body with the name "Solid Body 1(External Model)". In order to accomplish that, I have written the following code:

num = 1

NmdSlct = ExtAPI.DataModel.Project.Model.NamedSelections.AddNamedSelection()

NmdSlct.Name = "Bolt " + str(num)

NmdSlct.Location = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.WorksheetSpecific)

worksheet = NmdSlct.Location

worksheet.AddRow()

worksheet.SetEntityType(0,NamedSelectionWorksheetEntityType.Body)

worksheet.SetCriterion(0,NamedSelectionWorksheetCriterion.NamedSelection)

worksheet.SetOperator(0,NamedSelectionWorksheetOperator.Equal)

worksheet.SetStringValue(0,"Bolts")

worksheet.AddRow()

worksheet.SetAction(1, NamedSelectionWorksheetAction.Remove)

worksheet.SetEntityType(1,NamedSelectionWorksheetEntityType.Body)

worksheet.SetCriterion(1,NamedSelectionWorksheetCriterion.NameProperty)

worksheet.SetOperator(1,NamedSelectionWorksheetOperator.NotEqual)

worksheet.SetStringValue(1,"Solid Body " + str(num) + "(External Model)")

worksheet.Generate()

This creates a named selection, but the field where "Bolts" was supposed to be entered is blank. The line that is supposed to fill this field is worksheet.SetStringValue(0,"Bolts"). I have tried several different things to correctly fill that field. Using worksheet.SetValue(0,0) also leaves it blank, and using worksheet.SetValue(0,1) enters a path to D:\Documents\Projects\Analysis\FEA\Tests\Bolt\Bolt_files\dp0\global\MECH\SYS-3.mechdb for some reason.

I don't understand why the last result happens, but I believe the reason none of these commands produces the desired result is because the value being selected is not either a string or a number (which is what the two commands I've tried are expecting) but an item from the drop-down menu instead. Specifically, if I were doing this manually, I would select the "Bolts" named selection from the "Value" drop-down menu.

My question is therefore how do I create a named selection referencing another named selection using the ACTConsole?

More Tim Lewis's questions See All
Similar questions and discussions