How do I change the transparency of a composite w/ VBA

How do I change the transparency of a composite w/ VBA

JBEDsol
Collaborator Collaborator
529 Views
3 Replies
Message 1 of 4

How do I change the transparency of a composite w/ VBA

JBEDsol
Collaborator
Collaborator

I have a large assy from a vendor that's all surfaces.  I want to write a code that traverses the assy and changes all the composites full of surfaces from transparent to non transparent.  I can't find the object/property to do this.  Any ideas.

0 Likes
530 Views
3 Replies
Replies (3)
Message 2 of 4

Sergio.D.Suárez
Mentor
Mentor

Hi, is this what you are trying to achieve?
This will remove the transparency of all your worksurfaces

 

Dim oDoc As Document = ThisDoc.Document

For Each oWS As WorkSurface In oDoc.ComponentDefinition.WorkSurfaces
oWS.Translucent = False
Next

 I hope this helps with your problem. Regards


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

Message 3 of 4

Sergio.D.Suárez
Mentor
Mentor

What I shared before is an ilogic rule code, here you have the same code in VBA.

 

Sub Translucent()
    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument
    Dim oWS As WorkSurface
    For Each oWS In oDoc.ComponentDefinition.WorkSurfaces
        oWS.Translucent = False
    Next
End Sub

I hope it is useful. Regards


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
Message 4 of 4

SteveK88
Advocate
Advocate

I Made it as a toggle...

 If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then
    MessageBox.Show("This must be a PART document !", "iLogic",MessageBoxButtons.OK,MessageBoxIcon.Error)
    Return
End If
 
Dim oDoc As Document = ThisDoc.Document

For Each oWS As WorkSurface In oDoc.ComponentDefinition.WorkSurfaces
	If oWS.Translucent = False
		oWS.Translucent = True
	Else 
		oWS.Translucent = False
	End If
Next

 

 

0 Likes