Hi all,
Try searching this method "CreateSectionViewAt6" in API help, its not there, but when you record a macro to create a section view, it is using this method with different number of arguments than CreateSectionViewAt5.
Basically I am not able to create a section view of assembly with some parts excluded. Passing the components object for the argument "ExcludedComponents" is not giving me any different result at all.
Code I am writing is:
SolidworksApi macrosStatus = DrawDoc.ActivateView("View1")
swView = DrawDoc.ActiveDrawingView
swSketchSegment = ModelDoc.SketchManager.CreateLine(X1, Y1, 0.0#, X2, Y2, 0.0#)
Dim excludedComponents As Object
excludedComponents = GetExcludeComp(swView)
swView = DrawDoc.CreateSectionViewAt5(0.2, 0.14, 0, "A", 1, excludedComponents, 0)
swSectionView = swView.GetSection
' Set some section-view settings
swSectionView.SetAutoHatch(True)
swSectionView.SetLabel2("A")
swSectionView.SetDisplayOnlySurfaceCut(False)
swSectionView.SetPartialSection(True)
swSectionView.SetReversedCutDirection(True)
swSectionView.SetScaleWithModelChanges(True)
swSectionView.CutSurfaceBodies = True
swSectionView.DisplaySurfaceBodies = True
swSectionView.ExcludeSliceSectionBodies = True
swSectionView.SetExcludedComponents(excludedComponents)
ModelDoc.ForceRebuild3(False)
Private Function GetExcludeComp(swView As View) As Object
Dim RefComp As Object
Dim RefModelDoc As ModelDoc2 = swView.ReferencedDocument
Dim AssmDoc As AssemblyDoc
If RefModelDoc.GetType = swDocumentTypes_e.swDocASSEMBLY Then
AssmDoc = RefModelDoc
RefComp = AssmDoc.GetComponents(False)
End If
Dim ExcludeComp(0) As Object
Dim Count As Integer = 0
For Each Comp As Component2 In RefComp
'ReDim Preserve ExcludeComp(Count)
If Not Comp.Name2.Equals(UCase(Part) & "-1") Then
ExcludeComp(Count) = Comp ' Adding all Components other that "Part-1"
Count += 1
End If
Next
Return ExcludeComp
End Function