Jump to content

Wedges and custom attributes to CSV


Recommended Posts

How can i export all wedge attributes and custom attributes i created along the line into a single csv?

I made this work with CSV TOP node but i had to manually write the attributes.

Using option 'By Attribute' i can specify 'wedgeattribs' as the attribute array to read from, but the other custom made attributes do not appear there

Also tried in a python script

work_item.attribNames()

but this gives you every attribute listed - even the ones created automatically like the value type for each wedge attribute

 

Link to comment
Share on other sites

I ended up having all my custom attributes start with "__" for example "__myattrib"

So i took the wedgeattribs list and the attribNames() list - filtered the last on to keep only names with "__" as a substring

and finally merged them and wrote them to an attribute.

 

import pdg

active_item = pdg.EvaluationContext.workItem()
attribs = work_item.attribNames() #get all attribute names
search = "__"
myattribs = [attr for attr in attribs if search in attr]  #filter them - my custom attributes begin with __

data = work_item.data
wedges = data.stringDataArray("wedgeattribs") # get all wedges attributes

values = myattribs + wedges #merge two lists

work_item.setStringAttrib('a', values) #create string array atribute to use in csv output

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...