Hide Table of Contents

Set Transparency of Unmodified Components in Large Design Review Assembly Example (VB.NET)

This example shows how to:

  • open an assembly in Large Design Review mode
  • open, modify, save, and close an assembly component, and
  • set the transparency level of unmodified components in the assembly.
'----------------------------------------------------------------------------
' Preconditions: 
' 1. Make a copy of install_dir\samples\tutorial\api\oleostrut.sldprt.
' 2. Run the macro.
'
' Postconditions:
' 1. An assembly document opens in Large Design Review mode.
' 2. An assembly component opens and is modified, saved, and closed.
'    a. When prompted to rebuild, click Rebuild and save document.
'    b. When prompted to update the graphics data in Large Design Review,
'       click Yes.
' 3. The transparency level of unmodified components in the assembly is set to 0.75.
' 4. Interactively close the assembly document.
' 5. Interactively replace the just-modified install_dir\samples\tutorial\api\oleostrut.sldprt
'    document with the copy you made in step 1 of Preconditions.
' ---------------------------------------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics
 
Partial Class SolidWorksMacro
 
    Public Sub main()
 
        Dim swModel As ModelDoc2
        Dim swModelDocExt As ModelDocExtension
        Dim swAssemblyDoc As AssemblyDoc
        Dim fileName As String
        Dim status As Boolean
        Dim errors As Integer, warnings As Integer
 
        ' Open assembly in Large Design Review mode
        fileName = "C:\Program Files\SolidWorks Corp\SolidWorks\samples\tutorial\api\landing_gear.sldasm"
        swModel = swApp.OpenDoc6(fileName, swDocumentTypes_e.swDocASSEMBLY, swOpenDocOptions_e.swOpenDocOptions_ViewOnly, "", errors, warnings)
        swModelDocExt = swModel.Extension
        swAssemblyDoc = swApp.ActiveDoc
 
        ' Open component, modify it, and save it
        Dim swCompModel As ModelDoc2
        status = swModelDocExt.SelectByID2("oleostrut-1@landing_gear""COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
        swApp.OpenDoc6("C:\Program Files\SolidWorks Corp\SolidWorks\samples\tutorial\api\oleostrut.sldprt", 1, 0, "", errors, warnings)
        swApp.ActivateDoc3("oleostrut.sldprt"False, swRebuildOnActivation_e.swUserDecision, errors)
        swCompModel = swApp.ActiveDoc
        swCompModel.ClearSelection2(True)
        status = swModelDocExt.SelectByID2("Sketch9""SKETCH", 0, 0, 0, False, 0, Nothing, 0)
        swCompModel.EditSketch()
        swCompModel.ClearSelection2(True)
        status = swModelDocExt.SelectByID2("D3@Sketch9@oleostrut.SLDPRT""DIMENSION", 0.0792805491990847, -0.020779176201373, 0, False, 0, Nothing, 0)
        Dim swDimension As Object
        swDimension = swCompModel.Parameter("D3@Sketch9")
        swDimension.SystemValue = 0.025
        swCompModel.ClearSelection2(True)
        status = swCompModel.Save3(swSaveAsOptions_e.swSaveAsOptions_SaveReferenced, errors, warnings)
        swApp.CloseDoc("oleostrut.sldprt")
 
        ' Set the transparency level of unmodified components in the assembly
        swAssemblyDoc.LargeDesignReviewTransparencyLevelDynamic = True
        swAssemblyDoc.LargeDesignReviewTransparencyLevelEnabled = True
        swAssemblyDoc.LargeDesignReviewTransparencyLevel = 0.75
        Debug.Print("Transparency level: " & swAssemblyDoc.LargeDesignReviewTransparencyLevel)
        Debug.Print("  Enabled = " & swAssemblyDoc.LargeDesignReviewTransparencyLevelEnabled)
        Debug.Print("  Dynamic = " & swAssemblyDoc.LargeDesignReviewTransparencyLevelDynamic)
 
    End Sub
 
 
    ''' <summary>
    ''' The SldWorks swApp variable is pre-assigned for you.
    ''' </summary>
    Public swApp As SldWorks
 
 
End Class


Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Set Transparency of Unmodified Components in Large Design Review Assembly Example (VB.NET)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2013 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.