How to set the transparency and RGB color of python script

How to set the transparency and RGB color of python script

李榕华|Ronghua.LI
Advisor Advisor
3,490 Views
9 Replies
Message 1 of 10

How to set the transparency and RGB color of python script

李榕华|Ronghua.LI
Advisor
Advisor

I want to use Python script to create components, but I can't find a way to set the transparency and RGB color of 3D solid.
Does any expert know the solution to this problem?


李榕华

13489140049@qq.com




0 Likes
Accepted solutions (2)
3,491 Views
9 Replies
Replies (9)
Message 2 of 10

jabowabo
Mentor
Mentor

You cannot do this inside of Python scripts for parts.

Message 3 of 10

李榕华|Ronghua.LI
Advisor
Advisor

I know that there is no corresponding function in that document.

But I found a way to set the color in @h_eger  reply.

已解决: Re: Python script assistance - Autodesk Community - AutoCAD Plant 3D

 

I hope there are other functions that can meet this requirement.


李榕华

13489140049@qq.com




0 Likes
Message 4 of 10

h_eger
Mentor
Mentor
Accepted solution

Dear @李榕华|Ronghua.LI ,

 

there are also limits in Python scripting this is where they are exceeded.
This function cannot be influenced with Python scripting.

 

@jabowabo  has already answered your question.

-

If my reply was helpful, please give a "Kudo" or click the "Accept as Solution" button below (or both).

Hartmut Eger
Senior Engineer
Anlagenplanung + Elektotechnik
XING | LinkedIn

EESignature



Message 5 of 10

李榕华|Ronghua.LI
Advisor
Advisor

All right. I gave up.

Thanks for @h_eger  and @jabowabo  's reply.


李榕华

13489140049@qq.com




0 Likes
Message 6 of 10

joakim_lindh
Contributor
Contributor
Accepted solution

Hello everyone.
I was playing around with this color thing today again after finding out that it might work with changing colors of blocks inside a python script.

After some trail and error i did find out that .setColor() works perfectly on pythonscripts for plant 3D.

It uses the Color index RGB where for example 100=green 255=black and so on!

This is how i have done it on one of my scripts.

The only disadvantage is .uniteWith() is grabing the color of the object you are uniting to. So if you are looking for a colorful Python script you can group objects and then make a color for the group or just assign the color for each block and skip the unite part.

 

Body2 = CYLINDER(s, R=D2/2.0, H=FL1, O=0.0).rotateY(90).translate((-L2/2.0-FL1, 0.0, 0.0))
Body2.setColor(12)
Body3 = CYLINDER(s, R=D2/2.0, H=FL1, O=0.0).rotateY(90).translate((L2/2.0, 0.0, 0.0))
Body3.setColor(12)

 

 

joakimlindh_1-1631875157847.png

 

Message 7 of 10

李榕华|Ronghua.LI
Advisor
Advisor

Have you found a way to set the transparency of objects?


李榕华

13489140049@qq.com




0 Likes
Message 8 of 10

stephanYN6LU
Participant
Participant

Hi, I tried the obj.setColor(12), and there is no error in the "PLANTREGISTERCUSTOMSCRIPTS" command, I restarted the program and ran (TESTACPSCRIPT"SCRIPT") just to find nil, in the command line, with no items drawn. Is there a additional variable that needs to be imported to work?

 

Sidenote: I have managed to set the color, I concur nou with Joakim that it works

Also, i have tried oobj.setTransparency(40) and have not worked

 

 

 

 

 

0 Likes
Message 9 of 10

李榕华|Ronghua.LI
Advisor
Advisor

I tried the following functions without success.

    s01.transparency(T)
    s01.Transparency(T)
    s01.setTransparency(T)
    s01.entityTransparency(T)
    s01.entitytransparency(T)
    s01.EntityTransparency(T)
    s01.setEntityTransparency(T)

李榕华

13489140049@qq.com




0 Likes
Message 10 of 10

stephanYN6LU
Participant
Participant

Maybe have a look at this post:

https://forum.dynamobim.com/t/change-layer-transparency-in-autocad-file/47346/2

 

I think you have to wangle it a bit, I don't know how plant 3d will react to this script of Paolo_Emilio_Serra1,

but I guess its worth the try if needed so badly

0 Likes