You are aware that I am not an active and very useful person for the forum, but I still wanted to ask my question here first.
I thought I should ask here since it's the Macro section, if the section is wrong please let me know.
I want to set the appearance of a single part I selected in an assembly to Display Hidden Lines with a macro.
The file I am using is not a drawing, not a part file. assembly file. part will not be selected from the element tree. will be selected from the drawing area. so what do i have!
What does this macro do? select part and hide it.
I don't want to hide the part, I want to change the view style.
Code: Select all
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelectionMgr As SldWorks.SelectionMgr
Dim swEntity As SldWorks.Entity
Dim swComponent As SldWorks.Component2
Dim Part As Object
Dim PartName
Dim boolstatus As Boolean
Dim instance As IDatumTag
Dim value
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
' Get the selected entity (i.e., face, edge, vertex, or loop)
' and get the name of its component
Set swSelectionMgr = swModel.SelectionManager
Set swEntity = swSelectionMgr.GetSelectedObject6(1, -1)
Set swComponent = swEntity.GetComponent
Debug.Print "Name of component to which the selected entity belongs: " & swComponent.GetSelectByIDString
swComponent.ComponentReference = "TestComponentReference"
Debug.Print "Component reference added to the component to which the selected entity belongs: " & swComponent.ComponentReference
swModel.ForceRebuild3 True
' swComponent.Select False
' swModel.HideComponent2 'this hides the selected party.
' swModel.ViewDisplayHiddenremoved ' this changes all the parts.
' swComponent.DisplayMode = swComponentDisplayMode_e.swComponentHidden 'didn't work
' swComponent.DisplayMode = 0 'didn't work
End Sub
@gupta9665