Cancel
Showing results for 
Search instead for 
Did you mean: 

selecting bodies w/out journal identifier

Genius
Genius

is there a way to select solid bodies/features/sheet bodies w/out resorting to the journal identifier?

 

The code below(in python) works in most cases. The exception is when I have multiple bodies/features in one journal identifier.

 

ex: "Unparameterized_Feature(59)" has more than 1 sheet body in it

def function1(): 
for body in bodies: # theLw.Open() # theLw.WriteLine("Journal name is " + body.JournalIdentifier) somelist.append(body.JournalIdentifier) index_cntr+=1 return list ..........

def function2(listargument):
  for index in range(0, index_cntr)
 somevar=workPart.Bodies.FindObject(str(somelist[index]))
someobject.somemethod(somevar)

4 REPLIES

Re: selecting bodies w/out journal identifier

Honored Contributor
Honored Contributor

"is there a way to select solid bodies/features/sheet bodies w/out resorting to the journal identifier?"

 

Yes. I can't say that I've ever used the journal identifier to select a body object.

 

That said, it helps to know what body you want to select. If you are looking for the body(ies) in "Unparameterized Feature(59)", you might want to iterate through the feature collection until you find the desired feature, then use the [featureBody].GetBodies or the [feature].GetEntities methods.

 

The code you have posted appears a bit redundant. It loops through the body collection and stores the journal identifier of each body, then it loops through the list of identifiers to get the body. Why not just use the reference to the body object that you already have when iterating through the body collection?

Re: selecting bodies w/out journal identifier

Siemens Phenom Siemens Phenom
Siemens Phenom

It might help to understand the bigger picture of what you are trying to do. The code you show doesn't make much sense to me. Your making a list of body identifiers, then trying to get back to the body using the identifier. Why not just make a list of bodies in the first place? That way, when you iterate on the list you already have the body.

Re: selecting bodies w/out journal identifier

Genius
Genius

cowski1 wrote:

"is there a way to select solid bodies/features/sheet bodies w/out resorting to the journal identifier?"

 

Yes. I can't say that I've ever used the journal identifier to select a body object.

 

That said, it helps to know what body you want to select. If you are looking for the body(ies) in "Unparameterized Feature(59)", you might want to iterate through the feature collection until you find the desired feature, then use the [featureBody].GetBodies or the [feature].GetEntities methods.

 

The code you have posted appears a bit redundant. It loops through the body collection and stores the journal identifier of each body, then it loops through the list of identifiers to get the body. Why not just use the reference to the body object that you already have when iterating through the body collection?


Thanks for the reply. I edited the code to better explain the reundancy.

 

To clarify, I have one function where I use intersect (boolean operation) to project a solid body onto a 2D plane creating a sheet body for different layers (z=1mm, z=2mm, and so on).

 

In that same function, used a loop to store each sheet body in a list (using the journal identifier).

 

Then I have another function that selects each sheet body and performs some type of method on it.

 

Using the journal identifier works fine unless I have multiple sheet bodies in one plane. Ex: Concentric rings on plane z=20mm

 

 As you suggested, it might be better to combine the two functions into one. I'll look into it.

 

Re: selecting bodies w/out journal identifier

Honored Contributor
Honored Contributor

In your case, start by creating a list to hold the bodies that you will create. After you create the intersect feature, you will have a reference to the new feature in your code. Cast this feature to type "BodyFeature" and use the .GetBodies method; add the newly created bodies to your list. Now you can use the list of bodies later in your code when you need to process them.