Hi cowski,
try to put every thing together I found on engtips, code you offered
and change to export, the way I want , the snipped:
For Each obj As Body In mySelectedObjects
If obj.IsOccurrence Then
If obj.OwningComponent.DisplayName.Length > 30 Then
obj.SetName(obj.OwningComponent.DisplayName.Substring(0, 30))
Else
obj.SetName(obj.OwningComponent.DisplayName)
End If
Else
If obj.OwningPart.Leaf.Length > 30 Then
obj.SetName(obj.OwningPart.Leaf.Substring(0, 30))
Else
obj.SetName(obj.OwningPart.Leaf)
End If
End If
' lw.WriteLine(" Solid Body " + obj.name)
tagList.Add(obj.Tag)
Next
II = taglist.Count
Dim options as UFPart.ExportOptions
With options
.expression_mode = UFPart.ExportExpMode.CopyExpShallowly
.new_part = True
.params_mode = UFPart.ExportParamsMode.RemoveParams
End With
ufs.Part.ExportWithOptions(str_allcatprt, II, tagList.ToArray, options)
my problem is that the names of the bodies not get exported to the new part
... get lost
any help would be nice
regards
re: export with names
Unfortunately, I have not found a method to retain names when exporting to a new part with the 'remove parameters' option. It appears that 'remove parameters' not only removes the model parameters but also any metadata associated with the geometry (names, attributes, etc).
export with names
any other idea / way how to get the result
tia
export with names
This idea is untested, but I think it could be made to work:
Before exporting, loop through the solids and save information such as bounding box size and/or number of faces and/or number of edges; then after the export, loop through the solids in the new file and try to match them up. Once you find a match you can transfer object name, attributes, material, etc.
Not necessarily an easy or straightforward method, but it might work. Potentially problematic if you have an assembly with a lot of parts of similar shape/size.