AutoCAD Plant 3D Forum
Welcome to Autodesk’s AutoCAD Plant 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Plant 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to set the transparency and RGB color of python script

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
李榕华|Ronghua.LI
2327 Views, 9 Replies

How to set the transparency and RGB color of python script

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




9 REPLIES 9
Message 2 of 10

You cannot do this inside of Python scripts for parts.

Message 3 of 10

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




Message 4 of 10

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

All right. I gave up.

Thanks for @h_eger  and @jabowabo  's reply.


李榕华

13489140049@qq.com




Message 6 of 10

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

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


李榕华

13489140049@qq.com




Message 8 of 10
stephanYN6LU
in reply to: joakim_lindh

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

 

 

 

 

 

Message 9 of 10

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




Message 10 of 10

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report