Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Change active object's color

Change active object's color

antoine_allazHXWTY
Participant Participant
1,511 Views
8 Replies
Message 1 of 9

Change active object's color

antoine_allazHXWTY
Participant
Participant

Hello again,

 

Is there a way to change with a script the color of the object color's preview in the command panel (little square on the right)? I found nothing about it. And there is nothing in the SetUIColor # (color 0 0 0) too.

 

Best regards,

Antoine

0 Likes
1,512 Views
8 Replies
Replies (8)
Message 2 of 9

istan
Advisor
Advisor

$.wirecolor

0 Likes
Message 3 of 9

antoine_allazHXWTY
Participant
Participant

Unfortunately it's more complicate. This change only the object's color. But I'm looking for a script that change the little square's color (see the jpg file)

0 Likes
Message 4 of 9

dmitriy.shpilevoy
Collaborator
Collaborator

But it does exactly that, don't even need to force update anything.

0 Likes
Message 5 of 9

istan
Advisor
Advisor

what else you expect, when you do "$Box001.wirecolor = color 255 0 0" ?

 

0 Likes
Message 6 of 9

antoine_allazHXWTY
Participant
Participant

Hello,

 

I show you some screenshots. 

1 - the color of the square is green - I select nothing

2 - I choose to create a box, the square is still green

3 - I create a box, the box is blue and the square is blue

4 - after that the square is green again, but the next geomerty will be an other color

 

What i'm looking for is to change the square color with a script, and that the next new geomerty will be in the same color than the square.

I don't know if I explain it well ?

 

thanks for your help

0 Likes
Message 7 of 9

dmitriy.shpilevoy
Collaborator
Collaborator

Click on color square. In bottom left uncheck "assign random color".

0 Likes
Message 8 of 9

antoine_allazHXWTY
Participant
Participant

I did a script to have a toolbar with some color, when I click on it, it apply the wirecolor, and change the color of the new object also. This works, but I'm looking for changing the color of the square also.

 

fn applyColor Wcolor = (
for o in selection do (
o.wirecolor = Wcolor
)
redrawViews()
callbacks.removeScripts id:#VGCreate
callbacks.addScript #nodeCreated ("node=callbacks.notificationParam()"+"(node.wirecolor="+(Wcolor as string)+")") id:#VGCreate
)

-- button 1
imgTag btn_1 bitmap:(bitmap btn_w btn_h color:color_1) pos:[marge_l*1+(btn_w*0),marge_t] visible:true
colorpicker btn_clr_1 "" color:color_1 width:24 height:20 pos:[0,5] visible:false
on btn_1 click  do (undo on (applyColor color_1))
on btn_1 rightclick do (try(color_1 = colorPickerDlg (color_1) "Pick A Color:" alpha:true pos:[100,100])catch(color_1=color_1)
try(
btn_1.bitmap = (bitmap btn_w btn_h color:color_1)
setINISetting dataPath "color_1" "r" (color_1.r as string)
setINISetting dataPath "color_1" "g" (color_1.g as string)
setINISetting dataPath "color_1" "b" (color_1.b as string)
)catch()

 

0 Likes
Message 9 of 9

denisT.MaxDoctor
Advisor
Advisor

The system doesn't work the way you're trying to achieve. The color of the box you want to change is determined by the wirecolor of the newly created object if it's in the create state, or by the wirecolor of the last object created.

If you want each new object to be created with the wirecolor you specify, you'll have to create your own interface...

 

here is an example where I use scene events to call the "wire" change at the right moment (during manual creation only):

 

 

fn forceObjectWirecolor wirecolor:gray = 
(
	node = callbacks.notificationParam()
	if isvalidnode node and isCreatingObject (classof node) do node.wirecolor = wirecolor
)

callbacks.removeScripts id:#forced_wirecolor 
callbacks.addScript #nodecreated "forceObjectWirecolor wirecolor:orange" id:#forced_wirecolor 

 

 

0 Likes