You need to use the ClientGraphics API to create temporary section views. There is no way you can control the section created from the UI command, you would need to create your own graphics so you have control over them.
Take a look at GraphicsNode.SliceGraphics in the API help files. You can define a transient plane passed as input to the slice method. Using your device, you will be able to create a plane at the required position and modify the graphics.
Below is a VBA sample extracted from the help files. You can also take a look at the advanced section of the DevCamp material: in my ClientGraphics material I wrote a C# sample that allows to select a section plane and slice an assembly. The user can also click in the graphic window and the slicing side will be flipped, which illustrates how to update the plane.
Public Sub SliceClientGraphics()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
' Set a reference to component definition of the active part.
Dim oCompDef As PartComponentDefinition
Set oCompDef = oDoc.ComponentDefinition
Dim bApplyCap As Boolean
If MsgBox("Do you want an end cap?", _
vbQuestion + vbYesNo, "SliceGraphics") = vbYes Then
bApplyCap = True
Else
bApplyCap = False
End If
Dim oClientGraphics As ClientGraphics
Set oClientGraphics = oCompDef.ClientGraphicsCollection.Add("SliceGraphicsID")
' Create a new graphics node within the client graphics objects.
Dim oSurfacesNode As GraphicsNode
Set oSurfacesNode = oClientGraphics.AddNode(1)
Dim oTransientBRep As TransientBRep
Set oTransientBRep = ThisApplication.TransientBRep
' Create a copy of the solid body in the part
Dim oBody As SurfaceBody
Set oBody = oTransientBRep.Copy(oCompDef.SurfaceBodies.Item(1))
' Create client graphics based on the transient body
Dim oSurfaceGraphics As SurfaceGraphics
Set oSurfaceGraphics = oSurfacesNode.AddSurfaceGraphics(oBody)
' Color it red
oSurfacesNode.RenderStyle = oDoc.RenderStyles.Item("Red")
' Make the body in the part invisible
oCompDef.SurfaceBodies.Item(1).Visible = False
Dim oLineSegment As LineSegment
Set oLineSegment = ThisApplication.TransientGeometry.CreateLineSegment( _
oSurfacesNode.RangeBox.MaxPoint, oSurfacesNode.RangeBox.MinPoint)
Dim oRootPoint As Point
Set oRootPoint = oLineSegment.MidPoint
' Get the negative Z-axis vector
Dim oNormal As Vector
Set oNormal = ThisApplication.TransientGeometry.CreateVector(0, 0, -1)
' Create a plane normal to Z axis with the root point at the center of part
Dim oPlane As Plane
Set oPlane = ThisApplication.TransientGeometry.CreatePlane( _
oRootPoint, oNormal)
Dim oSlicingPlanes As ObjectCollection
Set oSlicingPlanes = ThisApplication.TransientObjects.CreateObjectCollection
Call oSlicingPlanes.Add(oPlane)
' Slice the client graphics
Call oSurfacesNode.SliceGraphics(bApplyCap, oSlicingPlanes)
' Update the view to see the result
ThisApplication.ActiveView.Update
End Sub
Regards,
Philippe.
______________________________________________________________
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
Philippe Leefsma
Developer Technical Services
Autodesk Developer Network