On 23/06/2013 at 08:30, xxxxxxxx wrote:
I hope someone can help me with my tiny problem if its not to much bother?
I've been trying to find a way to perform a similar function to the command line where by you can drag an objects property to the command line and it will give the details of that property. Is there any way to replicate this so that a user could highlight an objects property and a script act upon that highlighted property of that selected object?
I wasn't sure if it was possible so tried to go down a different route and it looks like I may be going down the wrong route. I've tried to make a text field input that a user can copy and paste from the command line into the text field and then get a script to work on that, but with no luck.
Has any one had any luck with this or a similar approach, I'd appreciate any ideas?
def main() :
obj = op.GetObject()
ud = op[c4d.ID_USERDATA,2]
pat = re.compile(r'[.*]')
strip_ud = pat.search(ud).group(0)
udata = "obj"+strip_ud
# This wont work as its a string not the actual objects property
udata = 500
# Below is what I'm trying to replicate.
#obj[c4d.PRIM_TUBE_HEIGHT] = 500
Here is a link to the scene file to: https://dl.dropboxusercontent.com/u/2802779/userdata_Aa.zip
On 23/06/2013 at 09:27, xxxxxxxx wrote:
i am not sure what you are trying to do. generally said it is impossible to access the
attribute manger in python. i think it is even not possible in cpp to get the currently
selected description element in the attribute manager. however:
1. the c4d module contains a dict with almost all ids. in some rare places there are
black spots, do not ask me why.
2. the pythonic way to do what you want are the getattr/setattr/getitem/setitem
methods. The bracket syntax is just a wrapper for those important methods. it depends
on the class you invoke __get/setitem__on what it does expect as the key parameter,
for a GeListNode it expects a DescID, so we have to get that id from the c4d dict first.
You can also invoke the __get/setitem__ methods directly on an objects BaseContainer,
~~where it does accept a key string as the key value. ~~Hm, just looked it up to be sure and
its turns out that a BaseContainer does not not accept strings either, i must have mixed
something up there, not sure why i thought so. So you have to stick with the DescIDs for
ID_NAME = getattr(c4d, 'ID_BASELIST_NAME') ID_RELPOS = getattr(c4d, 'ID_BASEOBJECT_REL_POSITION') def main() : if isinstance(op, c4d.BaseObject) : oldname = op.__getitem__(ID_NAME) print oldname op.__setitem__(ID_NAME, oldname + '_x') oldpos = op.__getitem__(ID_RELPOS) print oldpos if isinstance(oldpos, c4d.Vector) : oldpos += c4d.Vector(0,100,0) op.__setitem__(ID_RELPOS, oldpos) c4d.EventAdd() if __name__=='__main__': main()
On 26/06/2013 at 07:51, xxxxxxxx wrote:
Thanks littledevil. I suspected it wasn't possible. I'll have a look at the method you suggested and see how I get on, so thanks for that.
On 01/07/2013 at 15:08, xxxxxxxx wrote:
I recently saw Nitro4D's video for his MagicLoadTexture plugin and saw something very interesting at around the 6 minuet mark where by he adds some input boxes to his lay out and then is able to drag material properties into these input boxes. Does any one have any idea how he may have done this? This is the sort of thing I was looking for I think. It would be great to drag in what ever attribute you would like (with in reason) and then act upon it, an objects position for example. Any ideas?
Here is a link to the video:
On 01/07/2013 at 15:18, xxxxxxxx wrote:
you mean the textbox holding c4d.material.someid ? looks like a multilineedit with the python flag.
On 03/07/2013 at 01:53, xxxxxxxx wrote:
Ah, thanks I'll I have a look into that and hopefully getting it working. Thanks littledevil