This is Mangesh's Typepad Profile.
Join Typepad and start following Mangesh's activity
Mangesh
Recent Activity
Hello Xiaodong Liang,
Thank you for the sample code for DeleteFaceFeatures.
Well, we are working on a requirement in which a part file contains multiple shells (multiple solids). We want to get the mass properies of each shell independently.
For example in a part, we have 4 shells, to get mass properties of 1st shell, we want to remove other 3 shells. This can be achieved using DeleteFaceFeatures.
We have written the functionality as follows:
1. Collect the information for each shell - which other shell's faces should be deleted
2. The above information is stored in a collection
3. Then for each shell, other 3 shells are deleted and mass property is obtained.
But many times we are getting error message which says:
Run-time Error '-2147467259(80004005)':
Method 'Add' of object 'DeleteFaceFeatures' failed
The issue is definitely reproduced if we open the part file and do some operation like rotate and then run the program, otherwise it is intermittent issue.
The error message comes while creating the DeleteFaceFeature for second shell
Actually our program is in C++ and we always get error at following line:
Result = pDeleteFaceFeatures->Add(pFaceCollection, Heal, &pDeleteFace);
Result is always E_FAIL. The logic is exactly same as written in VBA.
Please advise what could be the reason for the same.
We could not attach the sample part file and it can be created by drawing 4 rectangles in a 2D sketch and extruding the same.
Sub DeleteFaceFeatureFunction()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
'oDoc.Activate
Dim oFace As Face
Dim TotalFaceShells As Integer
'Get total shell count
TotalFaceShells = oDoc.ComponentDefinition.SurfaceBodies.Item(1).FaceShells.Count
'Get all the shells
Dim oShells As FaceShells
Set oShells = oDoc.ComponentDefinition.SurfaceBodies.Item(1).FaceShells
Dim shellCnt As Integer
shellCnt = 1
Dim iInnerShellCnt As Integer
Dim oShellFaceColl As New Collection
'For each shell get which all other shells are to be removed
While (shellCnt <= TotalFaceShells)
Dim oFaceColl As FaceCollection
Set oFaceColl = ThisApplication.TransientObjects.CreateFaceCollection
iInnerShellCnt = 1
While (iInnerShellCnt <= TotalFaceShells)
If (shellCnt = iInnerShellCnt) Then
'If both shells are same, skip
Else
Dim oFaceShell As FaceShell
Set oFaceShell = oShells.Item(iInnerShellCnt)
For Each oFace In oFaceShell.Faces
Call oFaceColl.Add(oFace)
Next
End If
iInnerShellCnt = iInnerShellCnt + 1
Wend
Call oShellFaceColl.Add(oFaceColl, Str(shellCnt))
shellCnt = shellCnt + 1
Wend
shellCnt = 1
'oDoc.Activate
'For each shell delete other shells and get the area
While (shellCnt <= TotalFaceShells)
Set oFaceColl = oShellFaceColl.Item(shellCnt)
Dim oDeleteFace As DeleteFaceFeature
Set oDeleteFace = oDoc.ComponentDefinition.Features.DeleteFaceFeatures.Add(oFaceColl, False)
'Get area
Dim area As Double
area = oDoc.ComponentDefinition.MassProperties.area
Debug.Print area
'Delete the created feature
oDeleteFace.Delete True, True, True
shellCnt = shellCnt + 1
Wend
End Sub
Thanks & Regards,
Mangesh
delete face from part with the Inventor API
By Xiaodong Liang Issue Is there an example showing how to delete faces from a part using the Inventor API? Solution It is possible to delete the face from a part using the Inventor API. This is done by adding the faces to the DeleteFaceFeatures. A FaceCollection object is created and the faces...
Mangesh is now following The Typepad Team
Feb 19, 2016
Subscribe to Mangesh’s Recent Activity