Splitting STEP files in sub parts

HI. I'm using OCC 6.2 .net wrapper.
My goal is to load a STEP file and split it into several STEP with model structure.
The problem is that i don't know how to get the original part names:
The model structure is ok but all names changed in : "Open CASCADE STEP translator 6.2 8 xxxx" .

Here is the sub i use to read the main step file
Dim r As New STEPCAFControl.Reader

r.ReadFile(_fromFile)
r.Reader_.ClearShapes()
'MDTV-CAF
Dim D As New TDocStd.Document(New TCollection.ExtendedString("MDTV-CAF"))
r.SetNameMode(True)
r.SetColorMode(True)
r.SetPropsMode(True)
r.SetLayerMode(True)
r.SetMatMode(True)

If r.Transfer(D) Then

Dim ROOT As XCAFDoc.ShapeTool = XCAFDoc.DocumentTool.ShapeTool(D.Main)
Dim Colors As XCAFDoc.ColorTool = XCAFDoc.DocumentTool.ColorTool(D.Main)
Dim labels As New TDF.LabelSequence
Dim labelsCols As New TDF.LabelSequence
ROOT.GetFreeShapes(labels)
Colors.GetColors(labelsCols)
'ROOT.GetShapes(labels)

For ic As Integer = 1 To labelsCols.Length
Dim labelc As TDF.Label = labelsCols.Value(ic)
' MsgBox(GetName(labelc))
Next
Dim tn1 As TreeNode = Nothing
Dim tn2 As TreeNode = Nothing
Dim ts As syShape = Nothing
Dim nRoots As Integer = labels.Length
For i As Integer = 1 To nRoots
Dim label As TDF.Label = labels.Value(i)
' MsgBox(GetName(label))

If XCAFDoc.ShapeTool.IsAssembly(label) Then
Nodi.Text = GetName(label)
recurse(label, Nodi, Colors, r)

Else
MsgBox("nessun assieme trovato")

End If

Next
End If

here is the sub that recurse the structure

Public Sub recurse(parentLabel As TDF.Label, tNode As TreeNode, Colors As XCAFDoc.ColorTool, r As STEPCAFControl.Reader)
'Dim parentLabel As TDF.Label = node.Father.Label
Dim Livello As Integer = 0
contaParent(tNode, Livello)

If parentLabel.HasChild Then
Dim nodeIterator1 As New TDF.ChildIDIterator(parentLabel, XCAFDoc.General.ShapeRefGUID(), True)
While nodeIterator1.More
Dim node1 As TDataStd.TreeNode = CType(nodeIterator1.Value, TDataStd.TreeNode)
Dim questo1 As XCAFDoc.ShapeTool = XCAFDoc.DocumentTool.ShapeTool(node1.Label)
'Dim labels2 As New TDF.LabelSequence
'questo1.GetFreeShapes(labels2)
Dim Shp2 As TopoDS.Shape = XCAFDoc.ShapeTool.GetShape(node1.Label)
Dim tn2 As New TreeNode
If Not Shp2.IsNull Then
'Dim appo As String = tNode.Parent
Dim ts As syShape = Me.addSyShape(node1.Label, Shp2, Colors, Livello, r)

tn2 = tNode.Nodes.Add(ts.Id, ts.Name)
tn2.Tag = ts
tn2.ToolTipText = CType(tn2.Tag, syShape).Id

End If
If node1.HasFather Then
recurse(node1.Father.Label, tn2, Colors, r)

End If
nodeIterator1.Next()
End While

End If
Dim theFileName As String = IO.Path.GetDirectoryName(_tmpFile) & "\" & thisShape.Name & ".STP"
'Dim w1 As New STEPControl.Writer(r.Reader_.WS, True)
Dim w1 As New STEPControl.Writer()
w1.Transfer(shp, STEPControl.StepModelType.AsIs, True)
w1.Write(theFileName)
End Sub

thank you

here is the sub that write the STEPs

Sergey Pashkevich's picture

Hello. Please, send me file with these functions (main function and reverse)