How to create an empty 'Array[int]'
import array as arr a=arr.array('i', [1, 2, 3])+(Temp.Ids) unsupported operand type(s) for +: 'array' and 'Array[int]'
It seems like the types of "arr.array('i', [1, 2, 3]) " and "Temp.Ids" are different.
Answers
-
We'd need more info to understand the question. What Ansys product are you using. What is stored in Temp ? What are you trying to do exactly?
0 -
@Pernelle Marone-Hitz said:
We'd need more info to understand the question. What Ansys product are you using. What is stored in Temp ? What are you trying to do exactly?I'm using Mechanical 2021 R2.
I want to Initialize a variable which have empty value. Then use a loop to extend the Geo Ids of a named selection into the variable.
But when I try to extend the variable, it seems the data type didn't match.Temp is defined like this:
Temp=Model.AddNamedSelection() some code Temp.Ids a=arr.array('i', []) a+Temp.Ids
it returned "unsupported operand type(s) for +: 'array' and 'Array[int]'"
And I also tried below
Temp=ExtAPI.SelectionManager.CurrentSelection a+Temp.ids
it returned "unsupported operand type(s) for +: 'array' and 'List[int]'
0 -
@Pernelle Marone-Hitz said:
We'd need more info to understand the question. What Ansys product are you using. What is stored in Temp ? What are you trying to do exactly?I'm trying to Initialize an empty variable and use a loop to extend this variable with the named selection Ids list.
When I trying to do this I noticed the data type of the "named selection Ids" is 'Array[int]'
and I don't know how to create an empty 'Array[int]'0 -
I'm afraid I still don't have enough information to help. What Ansys product are you using ? Mechanical ? Maybe this post will help for ids of entities scoped in named selections: https://discuss.ansys.com/discussion/1309/identify-bodies-in-named-selections-and-make-dedicated-named-selections-for-each?utm_source=community-search&utm_medium=organic-search&utm_term=named+selections
0