Delete Custom Attribute in Attribute Holder

Delete Custom Attribute in Attribute Holder

Anonymous
Not applicable
3,383 Views
5 Replies
Message 1 of 6

Delete Custom Attribute in Attribute Holder

Anonymous
Not applicable

Hello guys,

I'm totaly stuck with Custom Attribute and Attribute Holder
I have created several customs attributes in an attribute holder but I want to be able to delete some of these attributes that will be useless when the parametering has been done

Thanks to a post on ScriptSpot I can list and get all the value using :

obj = $
CA_GMod = (custAttributes.get obj.modifiers[1] 1)
propsNamesArr = getPropNames (CA_GMod)
propsValuesArr = for n in propsNamesArr collect (getproperty CA_GMod n) 

I thought I could delete the attribute number 2 to 6 using

for n = 1 to propsNamesArr.count do (
    if n > 1 and n < 7 then (
        custAttributes.delete obj.modifiers[1] n
    )
)

But it's not working
I found out that custAttributes.delete obj.modifiers[1] 1 would delete all my custom attributes not the first one...

I have spent a lot of time trying codes found on internet to delete custom attributes and they are working on Base Level but with a modifier, there's nothing

And finally what is the advantage to use Attribute Holder as we can set attributes without using it (and do some wiring) ?

Thanks a lot

0 Likes
3,384 Views
5 Replies
Replies (5)
Message 2 of 6

blakestone
Collaborator
Collaborator

I do not have the solution and not sure if the ability to do this has been exposed in maxscript however a workaround would be to simply create a custom attribute for each parameter and using "custAttributes.delete" you can delete these as needed.

 

 

(
-- create dummy
	local o	= dummy()
		o.boxsize	= [10,10,10]
		o.position	= [0,0,0]
	
-- attributes
	local A1 = attributes "Attrib001" (
		parameters main rollout:params ( Data1 type:#string ui:data default:"" )
		rollout params "Attribute 001" ( edittext data "Data" type:#string )
	)
	
	local A2 = attributes "Attrib002" (
		parameters main rollout:params ( Data2 type:#string ui:data default:"" )
		rollout params "Attribute 002" ( edittext data "Data" type:#string )
	)
	
	local A3 = attributes "Attrib003" (
		parameters main rollout:params ( Data3 type:#string ui:data default:"" )
		rollout params "Attribute 003" ( edittext data "Data" type:#string )
	)
	
	local attrib = #(A1,A2,A3)
	local attrib_values = #("data 001","data 002","data 003")

-- add attributes to dummy
	for i=1 to attrib.count do (
		custAttributes.add o attrib[i]		
		setProperty o (getPropNames(custAttributes.get o i))[1] attrib_values[i]
	)	
)

example.png

 

--------------------------------------------------------------------------------------
Technical 3D Graphic Artist
Autodesk 3dsMax 2015 - Service Pack 4
--------------------------------------------------------------------------------------
0 Likes
Message 3 of 6

blakestone
Collaborator
Collaborator

I am not sure what type of data you're keeping your custom attributes but there is also the "User Defined" section which can be set for each: Right-Click Object > Object Properties > User Defined

Personally I find this method a lot easier to work with.

 

Documentation: http://docs.autodesk.com/3DSMAX/16/ENU/MAXScript-Help/index.html?url=files/GUID-AF1F51D4-449B-4C4D-9...

 

--------------------------------------------------------------------------------------
Technical 3D Graphic Artist
Autodesk 3dsMax 2015 - Service Pack 4
--------------------------------------------------------------------------------------
0 Likes
Message 4 of 6

Anonymous
Not applicable

Hi Blackstone,

 

Thanks for your help !

Yes, if I had defined my custom attributes like this I wouldn't be stuck and could easily delete them but I made the mistake to use Attribute Holder and it's more complicated to remove attributes

Now I have around 20 attributes with wiring and scripts controllers done by hand so it would be hard and too long to redefine this but yes, next time I will use scripting and normal custom attributes !

 

0 Likes
Message 5 of 6

Anonymous
Not applicable

In fact it's a car rig but due to bad implementation of 3dsmax for the rigging stuff, I have problem importing several rigged car. One is ok but import two and you get script controller errors and other bad things like some custom attributes not working, this is why I have to freeze some custom attributes parameters and delete them (it's ok for freezing and I'm stuck with deleting)

It's sad to see that 3dsmax could not achieve a nice robust rig implementation as it's a so old program (but the problem comes perhaps from this !)

I'm working with c4d and modo where I have developped the same rig and I can import as many car rig in the scene without any problem, everything go smooth and is independant.

 

I've already red some things on User Defined, it's ok to retain data but it's not the purpose here

Thanks anyway 😉

0 Likes
Message 6 of 6

Anonymous
Not applicable

Ok, I have found that in fact I want to delete parameters of a custom attribute nested in attribute holder

I only have one custom attribute named by default Custom Attribute by max and lots of parameters in it

Sorry for the mistake but I was lost with terms...

0 Likes