Message 1 of 15
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi;
Invnentor 2022
API: VB.NET VisualStudio
i try to Select a Face in Assembly Enviroment,
then i want to take the Insides EdgeLoop.
And from every Inside EdgeLoop take the CenterPoint, Create WorkAxis, WorkPlane, PlanarSketch and Extrude Negative, CutOperation - Make Holes.
The Problem is that this is Face in Other Part in Other Assembly.
This is my Code:
Public Sub CommandFunctionfweButton_07()
Dim oAsmDoc As AssemblyDocument = g_inventorApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry
'Create Matrix
Dim oMatrix As Matrix
oMatrix = oTG.CreateMatrix
'Create New Part in Main Assembly
Dim oNameFile As String = InputBox("text")
Dim oPartB As PartDocument = g_inventorApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject)
oPartB.SaveAs("C:\InventorAPI\1780-007\Part_B_" & oNameFile & ".ipt", False)
'Create NewOccurrence, PartComponentDefinition
Dim oOccPartB As ComponentOccurrence
oOccPartB = oAsmCompDef.Occurrences.AddByComponentDefinition(oPartB.ComponentDefinition, oMatrix)
oPartB.Close()
Dim oPartB_Def As PartComponentDefinition = oOccPartB.Definition
'Create New Sketch and Profile and Extrude
Dim oSketchPartB As PlanarSketch = oPartB_Def.Sketches.Add(oPartB_Def.WorkPlanes.Item(3), False)
Dim oRectangleLines As SketchEntitiesEnumerator
oRectangleLines = oSketchPartB.SketchLines.AddAsTwoPointRectangle(oTG.CreatePoint2d(0, 0), oTG.CreatePoint2d(40, 40))
Dim oProfile As Profile
oProfile = oSketchPartB.Profiles.AddForSolid
Dim oExtrudeDef As ExtrudeDefinition
oExtrudeDef = oPartB_Def.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kJoinOperation)
Call oExtrudeDef.SetDistanceExtent(1, PartFeatureExtentDirectionEnum.kPositiveExtentDirection)
Dim oExtrude1 As ExtrudeFeature
oExtrude1 = oPartB_Def.Features.ExtrudeFeatures.Add(oExtrudeDef)
'Select face form Other part in Other Assembly
Dim oFace As Face = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick a Face")
Dim oOcc1 As ComponentOccurrence = oFace.Parent.Parent
'Create faceProxy
Dim oFaceProxy As FaceProxy
Call oOcc1.CreateGeometryProxy(oFace, oFaceProxy)
'Create Loop and Select every InsideEdgeLoop, create a CenterPoint, Axis, Plane, Sketch, Circle and Extrude.
If oFace IsNot Nothing Then
For Each oEdgeloop As EdgeLoop In oFace.EdgeLoops
If Not oEdgeloop.IsOuterEdgeLoop Then
Dim oEdgeColl As EdgeCollection = oTO.CreateEdgeCollection
For Each oEdge In oEdgeloop.Edges
oEdgeColl.Add(oEdge)
Next
Dim oWorkpoint As WorkPoint = oPartB_Def.WorkPoints.AddAtCentroid(oEdgeColl)
Dim oWorkAxis As WorkAxis = oPartB_Def.WorkAxes.AddByNormalToSurface(oFace, oWorkpoint, False)
Dim oWorkPlane As WorkPlane = oPartB_Def.WorkPlanes.AddByNormalToCurve(oWorkAxis, oWorkpoint, False)
Dim oWorkSketch As PlanarSketch = oPartB_Def.Sketches.AddWithOrientation(oWorkPlane, oWorkAxis, True, True, oWorkpoint, True)
Dim oPointCenters As SketchPoint
oPointCenters = oWorkSketch.SketchPoints.Add(oTG.CreatePoint2d(0, 0), True)
Dim oCircle As SketchCircle
oCircle = oWorkSketch.SketchCircles.AddByCenterRadius(oPointCenters, 2)
Dim oProfile01 As Profile
oProfile01 = oWorkSketch.Profiles.AddForSolid
Dim oExtrudeDef02 As ExtrudeDefinition
oExtrudeDef02 = oPartB_Def.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile01, PartFeatureOperationEnum.kCutOperation)
Call oExtrudeDef02.SetThroughAllExtent(PartFeatureExtentDirectionEnum.kSymmetricExtentDirection)
Dim oExtrude2 As ExtrudeFeature
oExtrude2 = oPartB_Def.Features.ExtrudeFeatures.Add(oExtrudeDef02)
End If
Next
End If
End Sub
Error:
Unknow Error
What i need to do with Proxy?
FaceProxy
EdgeLoopProxy
etc..
Thanks For Any Suggestion
Solved! Go to Solution.