Making Solid Body Translucent - iLogic Code

Making Solid Body Translucent - iLogic Code

IGLICAD
Contributor Contributor
767 Views
1 Reply
Message 1 of 2

Making Solid Body Translucent - iLogic Code

IGLICAD
Contributor
Contributor

Hello,

 

I would like to describ my problem for a quick.

 

I have multi body part with specific solid body names. The solid bodies represent parts in machine. Entire file as a one multi body part should be used as 3D block for presentations. One solid body and its transparency should be able to be switched between Yes and No by Boolean variable - double mode transparency On and Off. I tried to write a code which could fullfill that task, but I'm still struggling.

 

Take a look please:

 
Sub Main()

If
ABDECKUNG = True Then Call VollBodyTrans("Abdeckung_W_K_01", 1) Call VollBodyTrans("Abdeckung_W_K_02", 1) Call VollBodyTrans("Abdeckung_M_K_01", 1) Call VollBodyTrans("Abdeckung_M_K_02", 1) Call AbdeckungTrans("Polycarbonat - Rauch") Else If ABDECKUNG = False Then Call VollBodyTrans("Abdeckung_W_K_01", 0) Call VollBodyTrans("Abdeckung_W_K_02", 0) Call VollBodyTrans("Abdeckung_M_K_01", 0) Call VollBodyTrans("Abdeckung_M_K_02", 0) Call AbdeckungTrans("Galvanisiert") End If End Sub Sub AbdeckungTrans (AbdTrans As String) Feature.Color("Abdeckung_M_01") = AbdTrans Feature.Color("Abdeckung_M_02") = AbdTrans Feature.Color("Abdeckung_W_01") = AbdTrans Feature.Color("Abdeckung_W_02") = AbdTrans End Sub Sub VollBodyTrans (oBodyName As String, oBodyTransParam As Boolean) Dim oDoc As PartDocument oDoc = ThisApplication.ActiveDocument Dim oCompDef As ComponentDefinition oCompDef = ThisDoc.Document.ComponentDefinition Dim oSurface As WorkSurface Dim oBody As SurfaceBody Dim MyArrayList As New ArrayList i = 1 For Each SurfaceBody In oCompDef.SurfaceBodies oBody = oCompDef.SurfaceBodies.Item(i) MyArrayList.Add(oBody.Name) i = i + 1 Next j = 1 For Each SurfaceBody In oCompDef.SurfaceBodies oBody = oCompDef.SurfaceBodies.Item(j) For Each oSurface In oDoc.ComponentDefinition.WorkSurfaces If oBody.Name = oBodyName Then oSurface.Translucent = oBodyTransParam End If Next MyArrayList.Add(oBody.Name) j = j + 1 Next End Sub
 

 The name "Abdeckung_W_K_01" for instance is the name of particular solid body.

 

Could anyone help me out with that issue.

 

At the moment, the solid body changes its color but not transparency. Beside this there is no error message what so ever.

 

Take care,

 

Thomas

0 Likes
768 Views
1 Reply
Reply (1)
Message 2 of 2

Sergio.D.Suárez
Mentor
Mentor

What happens is that a surfacebody is not a worksurface. Worksurface has the traslucent property, but not a surfacebody. The surfacebody is what you know as "Solid1" for example.
Surfacebody is made up of faces.
You have multiple paths depending on what you are trying to achieve.
You could create a worksurface for each face in your solid and then make the solid invisible, and these created worksurfaces place them as translucents.
A solution that I see more appropriate would be if you could programmatically change the appearance of the part and put "Transparent" for example. (I have this access in Autodesk appeareance library)
This will make all solids transparent.
Then the solids that you do not want to be transparent could enter their properties and define another material, for example steel.

I think what you are proposing sounds good as an inventor idea. To be able to make a solid translucent. Cheers!!


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes