Notifications
Clear all

[Closed] [Solved] Assign material with suffix for only selection obj

Hi all,

i need a help.

a_onoff = $OBJ_1
for o in a_onoff do
(
–assign mat.
)

I use this loop to add material to an object with OBJ_1 suffix, it works fine. But I would need to add material for the suffix ** but only for objects that are selection.

i m try – for o in a_onoff where superclassof o == selection do – its no working

well thank you

8 Replies

try this:


(
	a_onoff = $OBJ_1
	for o in a_onoff where o.isSelected == true do
	(
		--assign mat.
	)
)

I don’t know why, but it doesn’t work.

if i use this, work good
–a_onoff = $OBJ_1
for o in selection where o.name == “OBJ_1_box_001” do
(
–assign mat.
)

but I don’t want to write the full name, but only the suffix – OBJ_1
I need a combination of “selection” and “suffix” in one loop

moment…
your code works but…
(
a_onoff = $OBJ_1
a_onoff_i = #($OBJ_1)
if rollStruct.rollout2.onoff1.state == true then(a_onoff = a_onoff_i )

for o in a_onoff where o.isselected == true do
(
–assign mat…
)
)

a_onoff – works
a_onoff_i – error

– if the “suffix” is at the beginning of the object’s name

(
	for o in selection where matchPattern o.name pattern"OBJ_1*" do
	(
		--	assign mat.
	)
)

– if the suffix is at the end of the object’s name

(
	for o in selection where matchPattern o.name pattern"*OBJ_1" do
	(
		--	assign mat.
	)
)

– if the “suffix” is somewhere inside the object’s name
– this will process all selected objects which has OBJ_1 in its name

(
	for o in selection where matchPattern o.name pattern"*OBJ_1*" do
	(
		--	assign mat.
	)
)

allright, i understand which diferent prefix, suffix or postfix.

i use these variant
(
a_onoff = $*OBJ_1* 
a_onoff_i = #($*OBJ_1*)
)

variant “a_onoff” do random assign all mat for all objects with suffix (every object have difgerent material)
variant “a_onoff_i” do random choice one mat from list for all objects with suffix (same material for all)

these scenario works good but problem is material is assign on every object hide/unhide and is very slow, becouse i have a lot of object which is hide.

these variant work ok
    (
    a_onoff = $*OBJ_1* 
    for o in a_onoff where o.isSelected == true do
    )

but

 these variant work not ok
(
 a_onoff_i = #($*OBJ_1*)
for o in a_onoff_i where o.isSelected == true do
)

maybe I need to change the definition of a_onoff_i so that all objects with seffix are considered as one object

Solved

(
	xx = #(for m in selection where MatchPattern m.name pattern:"*OBJ_1*" collect m )
	for o in xx do
	(
		--	assign mat.
	)
)

suffix is always after, prefix is before…

Yeah, I know. Because of this the first suffix is inside ” ”