Hide Table of Contents

Move Freeze Bar Example (VB.NET)

This example shows how to move the freeze bar to another location in the FeatureManager design tree.

'----------------------------------------------------------------------------
' Preconditions:
' 1. Open install_dir\samples\tutorial\api\FreezeBarNeedsRebuild2.sldprt.
' 2. Inspect the FeatureManager design tree:
'    * The freeze bar is below Boss-Extrude1 in the FeatureManager design tree.
'    * Boss-Extrude1 is frozen in the FeatureManager design tree.
'    * Boss-Extrude2 is unfrozen in the FeatureManager design tree.
'    * Boss-Extrude1 has freeze updates pending.
'    * Boss-Extrude2 has no freeze updates pending.
'    * The model needs to be rebuilt.
'
' Press F5 to run the macro:
' 1. Inspect the Immediate window to see which features have hidden locks.
' 2. Press F5 to continue.
'    * Freeze bar moved to the top of the FeatureManager design tree.
'    * Boss-Extrude1 is unfrozen.
' 3. Press F5 to continue.
'    * Freeze bar moved to the bottom of the FeatureManager design tree.
'    * Boss-Extrude1 and Boss-Extrude2 are frozen.
' 4. Press F5 to continue.
'    * Freeze bar moved to before Boss-Extrude2.
'    * Boss-Extrude1 is frozen.
'    * Boss-Extrude2 is unfrozen.
' 5. Press F5 to continue.
'    * Freeze bar moved to after Boss-Extrude2.
'    * Boss-Extrude1 and Boss-Extrude2 are frozen.
' 6. Press F5 to continue.
'    * Freeze bar moved to the top of the FeatureManager design tree.
'    * Boss-Extrude1 and Boss-Extrude2 are unfrozen.
' 7. Press F5 to continue.
'    * The model does not need to be rebuilt.
'    * Boss-Extrude1 and Boss-Extrude2 have no freeze updates pending.
' 8. Press F5 to close the model.
'
' Postconditions: Inspect the Immediate window.
'
' NOTE: Because the model is used elsewhere,
' do not save changes when closing it.
' ---------------------------------------------------------------------------


Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System
Imports System.Diagnostics

Partial Class SolidWorksMacro

    
Dim swModel As ModelDoc2
    
Dim swModDocExt As ModelDocExtension
    
Dim lRet As Long
    Dim featMgr As FeatureManager
    
Dim selMgr As SelectionMgr
    
Dim featFrozen As Feature
    
Dim featUnFrozen As Feature
    
Dim feat As Feature
    
Dim boolstatus As Boolean
    Dim bRetVal As Boolean
    Dim vfeats As Object
    Dim vfeat As Object

    Sub main()

        swModel = swApp.ActiveDoc
        swModDocExt = swModel.Extension
        featMgr = swModel.FeatureManager
        selMgr = swModel.SelectionManager

        Debug.Print(
"Number of Features is " & swModel.GetFeatureCount)

        vfeats = featMgr.GetFeatures(
True)

        
For Each vfeat In vfeats
            feat = vfeat
            Debug.Print(
"Feature Name from FeatureManager is " & feat.Name)
            Debug.Print(feat.Name &
" has a hidden lock? " & feat.IsHiddenLock)
        
Next

        boolstatus = swModDocExt.SelectByID2("Boss-Extrude1", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
        boolstatus = swModDocExt.SelectByID2(
"Boss-Extrude2", "BODYFEATURE", 0, 0, 0, True, 0, Nothing, 0)

        feat = featMgr.GetFreezeLocation
        
If Not feat Is Nothing Then
            Debug.Print("")
            Debug.Print(
"Freeze bar location is after " & feat.Name)
            Debug.Print(feat.Name &
" is frozen? " & feat.IsFrozen)
        
End If

        bRetVal = swModDocExt.NeedsRebuild2
        Debug.Print(
"Needs rebuild? " & bRetVal)

        featFrozen = selMgr.GetSelectedObject6(1, -1)
        Debug.Print(
"Feature " & featFrozen.Name & " has freeze updates pending? " & featFrozen.HasFrozenUpdatePending)
        featUnFrozen = selMgr.GetSelectedObject6(2, -1)
        Debug.Print(
"Feature " & featUnFrozen.Name & " has freeze updates pending? " & featUnFrozen.HasFrozenUpdatePending)
        Debug.Print(
"")

        swModel.ClearSelection2(
True)

        
Stop

        If (featFrozen.HasFrozenUpdatePending) Then
            lRet = featMgr.EditFreeze(swMoveFreezeBarTo_e.swMoveFreezeBarToBeforeFeature, featFrozen.Name, True)
            Debug.Print(
"Freeze bar moved to the top of the FeatureManager design tree. Press F5.")
            
Stop
            lRet = featMgr.EditFreeze(swMoveFreezeBarTo_e.swMoveFreezeBarToEnd, "", True)
            Debug.Print(
"Freeze bar moved to the bottom of the FeatureManager design tree. Press F5.")
            
Stop
            lRet = featMgr.EditFreeze(swMoveFreezeBarTo_e.swMoveFreezeBarToBeforeFeature, featUnFrozen.Name, True)
            Debug.Print(
"Freeze bar moved to before Boss-Extrude2. Press F5.")
            
Stop
            lRet = featMgr.EditFreeze(swMoveFreezeBarTo_e.swMoveFreezeBarToAfterFeature, featUnFrozen.Name, True)
            Debug.Print(
"Freeze bar moved to after Boss-Extrude2. Press F5.")
            
Stop
            lRet = featMgr.EditFreeze(swMoveFreezeBarTo_e.swMoveFreezeBarToTop, "", True)
            Debug.Print(
"Freeze bar moved to the top of the FeatureManager design tree. Press F5.")
            
Stop
        Else
            lRet = featMgr.EditFreeze(swMoveFreezeBarTo_e.swMoveFreezeBarToBeforeFeature, featFrozen.Name, True)
            lRet = featMgr.EditFreeze(swMoveFreezeBarTo_e.swMoveFreezeBarToEnd,
"", True)
            lRet = featMgr.EditFreeze(swMoveFreezeBarTo_e.swMoveFreezeBarToBeforeFeature, featUnFrozen.Name,
True)
            lRet = featMgr.EditFreeze(swMoveFreezeBarTo_e.swMoveFreezeBarToAfterFeature, featUnFrozen.Name,
True)
            lRet = featMgr.EditFreeze(swMoveFreezeBarTo_e.swMoveFreezeBarToTop,
"", True)
        
End If

        Debug.Print("")
        bRetVal = swModDocExt.NeedsRebuild2
        Debug.Print(
"Needs rebuild? " & bRetVal)

        Debug.Print(
"Feature " & featFrozen.Name & " has freeze updates pending? " & featFrozen.HasFrozenUpdatePending)
        Debug.Print(
"Feature " & featUnFrozen.Name & " has freeze updates pending? " & featUnFrozen.HasFrozenUpdatePending)

        feat = featMgr.GetFreezeLocation
' feat = Nothing if freeze bar is at the top of FeatureManager design tree
        If Not feat Is Nothing Then
            Debug.Print(feat.Name & " is frozen? " & feat.IsFrozen)
        
End If

        Debug.Print("Press F5 to close the model.")
        
Stop

        swApp.CloseDoc("")

    
End Sub

  
    
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:   Move Freeze Bar 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) 2012 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.