View Full Version : CustomAttributes and instanced objects
48design 05-15-2009, 10:29 AM Hi,
I'm trying to do a script where I have to put custom attributes onto objects. Problem is: these objects can also be instances but the custom attributes should not get instanced!
Can someone help me, please?
|
|
legie
05-15-2009, 10:46 AM
edit: see posting below
Zbuffer
05-15-2009, 10:48 AM
Then you should references, not instances
legie
05-15-2009, 10:49 AM
Hi,
you can control that with the "BaseObject:<bool>" argument in the "custattributes.add" command.
E.g.
custattributes.add $ TestDataCaDef BaseObject:false
...will add the Custom attribute only to the selection without affecting its instances. "BaseObject:true" would add an 'instanced' custom attrbute to the selection and all its instances. Changing the value of that CA, would change the value for all instances as well.
48design
05-15-2009, 11:39 AM
Okay, thank you!
I tried that before but then the following doesn't work anymore:
paramWire.connect obj.seedPlanter[#disturb_rad] newSphere.baseObject[#radius] "disturb_rad"
(obj is the object with custom attribute "disturb_rad" in attributes set "seedPlanter")
seed_attributes = attributes "seedPlanter"
(
parameters main
(
disturb_rad type:#float default:0
disturb_bbox type:#node
)
)
What do I do wrong? :o/
legie
05-15-2009, 12:51 PM
No clue about that, sorry. I have no experience with param wiring....
Can you show us the warning you get?
48design
05-15-2009, 03:50 PM
The objects did not seem to be wired anymore... but I think I found the bug at another part of my script... sorry! I added the customAttribute over and over again to the object, even if it had it...
Generating a ClassID for the attributes helped me getting rid of this.
Thanks for your help!
guapador
05-19-2009, 01:20 AM
48design,
did you figure it out? I'm trying to do a similar thing using a custom attribute "distance" to drive "rectangle width" parameter at the base of my modifier stack. I want the base geometry to be instanced but the attribute to be unique. I'm trying to build a sytem like the one shown here> http://designreform.net/2008/02/21/circle-pattern-wire-parameters/ only I'd like the flexability to have instanced panels to control the whole system rather than copies as shown in the tutorials. By your question, it sounds like you were trying to create an instanced array and then apply the custom attribute with a maxscript after. Is that correct? Any help you can give me would be greatly appreciated.
48design
05-20-2009, 09:38 AM
Hi guapador,
I made it like this:
thing_attrib = attributes "attribThing" attribID:#(0x12345678, 0x12345678)
(
parameters main
(
rad type:#float default:0
bbox type:#node
use type:#boolean default:true
)
)
The attribID is generated by typing genClassID() into the Listener.
custAttributes.add obj thing_attrib BaseObject:false
After that the attribute is unique and is not put onto the object more than once.
newSphere = Sphere radius:20 segs:8
paramWire.connect obj.attribThing[#rad] newSphere.baseObject[#radius] "rad"
I hope that helps! Would be nice to see your script in action after you finished it.
guapador
05-20-2009, 06:33 PM
Thanks 48 design. I have very little experience with Maxscript so it will probably take me a while to implement. In the meantime, I have found a procedure that allows me to locate a large amount of wired, float expression constrained panels along non-flat surfaces in a predictable way. Unfrotunately, they aren't instanced so I have to go through the process every time I want to update my system.
First, I create a series of planes arranged in any way I want. I can use a maxscript to distibute along a surface or spline in order to acheive whatever my desired shape may be.
Second, I create the exact same number of panels using the internal Max array function. (This automatically updates variables in my float expression to remain self referential. For example variable PointPos in recatangle01 points to the vector position of rectangle01. When arrayed as copy, PointPos in rectangle02 points to vector position of rectangle02 and so on. Using a maxscript to copy the panels doesn't update the variable in this way.)
Then I use the multiple align script below to align the panels to the series of plane objects that I created in step one.
select panel and type and execute in the listener:
PanelArr = selection as array
select all you planes and execute
PlaneArr = selection as array
then execute:
for i = 1 to panelArr.count do panelarr[i].transform = planearr[i].transform
This procedure allows me to create a sytem like the one on the Designreform.net site and arrange the panels along non-flat surfaces in a predictable way. Thanks to floopyb for the above script.
CGTalk Moderation
05-20-2009, 06:33 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.