Exclude Component Occurrence from Section View

Exclude Component Occurrence from Section View

philipp.rockenschaubDDSYJ
Contributor Contributor
561 Views
4 Replies
Message 1 of 5

Exclude Component Occurrence from Section View

philipp.rockenschaubDDSYJ
Contributor
Contributor

Is there a way to exclude one specific component occurrence from a section view via code?

 

I am currently working on a project that automatically creates an assembly and a drawing of it based on some data that is provided. As part of the drawing I need one section view through everything with one component occurrence in the assembly excluded from the section.

Manually I can just right click on the browser node and set Section Participation to none but I have not found a way to do it only with code.

 

I also want to turn on the hidden lines of just this one occurrence.

 

Does anyone know how to do this? Thank you!

0 Likes
Accepted solutions (1)
562 Views
4 Replies
Replies (4)
Message 2 of 5

A.Acheson
Mentor
Mentor

Hi @philipp.rockenschaubDDSYJ 

 

Here are the two methods found under the SectionDrawingView Object 

SectionDrawingView.SetIncludeStatus( Object As Object, Include As Boolean )
SectionDrawingView.SetHiddenLinesStatus( Component As Object, visibleStatus As HiddenLinesStatusEnum )

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 5

philipp.rockenschaubDDSYJ
Contributor
Contributor

Hello @A.Acheson 

 

Thank you for the quick reply.

The SetHiddenLinesStatus method works great, I don't know why I missed it when I searched through the help.

The SetIncludeStatus method is not what I am looking for though. It only sets whether or not sketches, work features and surface features are includes in the view. I do want the occurrence to be visible in the view just not sectioned.

 

I found a way to do it with the command manager but for that I need to have the correct browser node selected and I don't know how

ThisApplication.CommandManager.ControlDefinitions(“AllowNoneParticipation”).Execute()

 

0 Likes
Message 4 of 5

A.Acheson
Mentor
Mentor
Accepted solution

I had another look through the API help and it looks like they haven't provided a section method which is a pity because their is a lot of work to get the command to work. I would suggest post this in the idea section if it isn't there already.

 

I kind of wanted to do this for myself as I also have a need for it so here is the method to select the browser node of the occurrence based on the view selected and occurrence name given. 

Selecting the view through the command manager has the added benefit of being the starting point for the browser node loop this means you don't have to loop through other views improving the speed. 

Sub Main
	
    Dim doc As Document = ThisDoc.Document
	
	'Make this a single transaction.
	Dim trans As Transaction = ThisApplication.TransactionManager.StartTransaction(doc, "Sectioning Occurrence") 
	
	ThisApplication.StatusBarText = "Sectioning Occurrence..."
	
    Dim bp As BrowserPane = doc.BrowserPanes("DlHierarchy")
	
	'Option for Section Method.
	Dim sectionView As SectionDrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a Section drawing view")

	secBool = InputRadioBox("Pick One", "Section", "No Section ", secBool, Title := "iLogic")
	
	Dim occName As String = InputBox("Enter an OccurrenceName", "OccurrenceName", "Coupling:1")
	
	'Select the view in order to pick up the view node and reduce recursion time.
	ThisApplication.CommandManager.DoSelect(sectionView)
	
	'Find the occurrence by imputting occurrence name.
	occ = GetOccurrence(occName ,sectionView.DrawingCurves) 
	
	'Find valid nodes with occurrence name in their path.	
	GetViewNode(bp.TopNode.BrowserNodes, occName)
	
	ThisApplication.CommandManager.ControlDefinitions.Item("AppBrowserCollapseAllCmd").Execute2(True)
	
	trans.End
	ThisApplication.StatusBarText = "Rule Finished"
	
End Sub

Dim  occ As ComponentOccurrence
Dim secBool As Boolean 

Function GetOccurrence(occName As String, curves As DrawingCurvesEnumerator) As ComponentOccurrence

	For Each curve As DrawingCurve In curves
		For Each curveSegment As DrawingCurveSegment In curve.Segments
			Try
				Dim modelGeom As Object = curve.ModelGeometry
				occ = modelGeom.ContainingOccurrence
			Catch
			End Try
			If occ.Name = occName Then
				Logger.Info("found occ from curve " & occ.Name)
				Return occ
			End If
		Next	
	Next
End Function

'Get Drawing view node selected
Sub GetViewNode(nodes As BrowserNodesEnumerator, occName As String) 
    For Each node As BrowserNode In nodes
        If node.Selected Then
			
			'Slow down events to allow node to be found.
			ThisApplication.UserInterfaceManager.DoEvents()
			node.EnsureVisible
			node.DoSelect
			'Logger.Info("Drawing View found" & node.FullPath)
			'Loop through found view nodes.
			GetoOccurrenceNode(node.BrowserNodes,occName)
			Exit For
        End If
		'Not found so call sub routine again.
        GetViewNode(node.BrowserNodes,occName)
    Next
End Sub
		
Sub GetoOccurrenceNode(nodes As BrowserNodesEnumerator,occName As String) 
    For Each node As BrowserNode In nodes
	       If node.BrowserNodeDefinition.Label = occName Then
			  SectionCmd(secBool,node)
			  'Logger.Info(node.FullPath)
			  Exit For
			End If
		'Not found so call sub routine again.
        GetoOccurrenceNode (node.BrowserNodes,occName)
    Next	
End Sub


Sub SectionCmd(secBool As Boolean, bn As BrowserNode)

	bn.EnsureVisible
	bn.DoSelect
	Dim cd As ControlDefinition
	If secBool = True
		cd = ThisApplication.CommandManager.ControlDefinitions(“AllowSectionParticipation”)
	ElseIf secBool = False
		cd = ThisApplication.CommandManager.ControlDefinitions(“AllowNoneParticipation”)
	End If
	cd.Enabled = True
	cd.Execute
End Sub

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 5

philipp.rockenschaubDDSYJ
Contributor
Contributor

Thank you, with that I was able to make it work.

0 Likes