A new version of Cineversity has been launched. This legacy site and its tutorials will remain accessible for a limited transition period

Visit the New Cineversity
   
 
Using python to group and ‘hierarchize’ objects based on part of the objects’ names
Posted: 27 June 2014 01:00 PM   [ Ignore ]  
Total Posts:  16
Joined  2014-06-17

We’ve included a simplified scene file. What you are looking at is a small chunk of a protein molecule, imported into the scene using the ePMV plugin. Each visible object represents an atom, and each atom has an automatically generated name. Open up the 1crn_2:A_cpk null to see the list.
We want to use the information in each name to group sets of similar atoms. The naming system is consistent no matter what protein is imported. We want to group items that share the first nine characters of their name…e.g., the first 8 objects in the file start with “S.2.0.Y44”.

Let’s assume the user has selected the null object 1crn_2:A_cpk. This is what we want the script to do:

For each set of atoms under the selected null object that share the first nine characters of their name,
~Find the atom whose name includes “.CB”
~Convert that “.CB” atom to a null object and name it with the 7th, 8th and 9th characters of the name (e.g., Y44)
~Place that new null object under the null that was originally selected (e.g., 1crn_2:A_cpk)
~Group the set of atoms (that share the first nine characters of their name) under this new null object

https://drive.google.com/file/d/0Bw5GC4jhbEtLSy1qMnc1bkVTZFk/edit?usp=sharing

We really appreciate your help, as this will help us move forward with the majority of our project!

Profile
 
 
Posted: 30 June 2014 06:52 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
Total Posts:  406
Joined  2006-01-24

I don’t particularly feel like doing the stuff I should do today, so I’ve taken a stab at this. Not sure if I understood correctly, but the attached script does what I think you’re asking.

File Attachments
atoms.zip  (File Size: 1KB - Downloads: 186)
Profile
 
 
Posted: 01 July 2014 11:53 AM   [ Ignore ]   [ # 2 ]  
Total Posts:  16
Joined  2014-06-17

Wow, that is exactly what we needed!  Thank you so much for your help!

Now, one question we still have is that we need this script to iterate through all the names (7th through 9th characters), but right now the script stops after it groups Y44 into a null.  We originally included a simplified scene file, which excluded groups 1-42.  However, we do need the script to group all 44 names in our full scene file.  Do you have any suggestions as to how we could incorporate a loop to make the script continue to cycle through the atoms and create groups for all the remaining “.CB”‘s? 

Again, thank you so much for your assistance!

-Nate

P.S. - If we run the script more than once, it will keep regrouping Y44 into nulls within nulls before searching through number 43, 42, 41, etc. We want the script to loop from 44 down to 1.  Also, if you would like a full scene file, we would be happy to share that with you.

Profile
 
 
Posted: 01 July 2014 01:24 PM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
Total Posts:  406
Joined  2006-01-24

New version attached. See if that does the trick.

File Attachments
atoms.zip  (File Size: 1KB - Downloads: 113)
Profile
 
 
Posted: 01 July 2014 02:27 PM   [ Ignore ]   [ # 4 ]  
Total Posts:  16
Joined  2014-06-17

That script seems to be the same script that you sent earlier.  What exactly did you change between the newer and older versions?

Thanks,

Profile
 
 
Posted: 01 July 2014 03:29 PM   [ Ignore ]   [ # 5 ]  
Administrator
Avatar
Total Posts:  406
Joined  2006-01-24

Oops. Wrong file.

File Attachments
atoms.zip  (File Size: 1KB - Downloads: 141)
Profile
 
 
   
 
 
‹‹ Q&A_miscellaneous      Motion Blur Problem ››