I just wanted to create a punchtool on a point . There type missmatch i dont understand why , if some one could help me i would very helpfull .
Sub Bohrungen()
'set a reference to active document
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
' set a reference to shett metal metal definition
Dim oShMetDef As SheetMetalComponentDefinition
Set oShMetDef = oPartDoc.ComponentDefinition
'assume a face has been selected in the part
Dim oFace As Face
Set oFace = oPartDoc.SelectSet(1)
'Set reference to the transient geometry
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
'Make sure it is a planar face
If oFace.SurfaceType = kPlaneSurface Then
Dim oPlanarSurface As Plane
Set oPlanarSurface = oFace.Geometry
Dim oSketch As PlanarSketch
Set oSketch = oShMetDef.Sketches.Add(oFace)
Dim oPoint1 As SketchPoint
Set oPoint1 = oSketch.SketchPoints.Add(oTG.CreatePoint2d(-10, 3.5), False)
Else
MsgBox ("pls select planar face")
End If
' create an Ifeaturedefinition object for a punch tool
Dim oSMFeatures As SheetMetalFeatures
Set oSMFeatures = oShMetDef.Features
Dim oiFeatureDef As iFeatureDefinition
Set oiFeatureDef = oSMFeatures.PunchToolFeatures.CreateiFeatureDefinition("J:\_Vorlagen\Inventor\Bibliothek\IDE\Punches\Langloch.ide")
'set the inpunt
' Dim oInput As iFeatureInput
' For Each oInput In oiFeatureDef.iFeatureInputs
'
' Dim oParamInput As iFeatureParameterInput
' Select Case oInput.Name
' Case "lg"
' Set oParamInput = oInput
' oParamInput.Expression = "1.6"
' Case "du"
' Set oParamInput = oInput
' oParamInput.Expression = "1.2"
' End Select
' Next
Dim oParamInput As iFeatureParameterInput
Set oParamInput = oiFeatureDef.iFeatureInputs.Item(1)
oParamInput.Expression = "16 mm"
Set oParamInput = oiFeatureDef.iFeatureInputs.Item(2)
oParamInput.Expression = "12 mm"
' Create the iFeature at 0 degree
Dim oPunchTool As PunchToolFeature
Set oPunchTool = oSMFeatures.PunchToolFeatures.Add(oPoint1, oiFeatureDef, 0, False) ' - here is problem i dont know what it is . Typen unverträglich (Fehler 13)
End Sub
Solved! Go to Solution.
Solved by leestanton0931. Go to Solution.
Solved by cidhelp. Go to Solution.
Hello @b.kushaiynov ,
as first argument of PunchToolFeatures.Add you need an ObjectCollection.
See the API-Sample here:
https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-00CA6F7C-C067-4001-9894-166F1B130F0F
The error you're encountering, "Typen unverträglich (Error 13)" indicates a type mismatch, likely related to the parameters passed to PunchToolFeatures.Add. The issue could stem from the oPoint1 parameter not being in the expected type or format.
Here's a suggestion to fix it:
Ensure oPoint1 is of the correct type. Since PunchToolFeatures.Add expects a 3D point, but oPoint1 is created as a 2D point (CreatePoint2d), you should convert the 2D point to a 3D point.
You can do this by modifying:
to include a projection or use a 3D point (CreatePoint instead of CreatePoint2d).
You also need to ensure the face and other parameters are set properly before adding the punch tool.
This should resolve the type mismatch issue.
Thanks for Clarification. I just didnt understand the issue. What was wrong.
PunchToolFeatures.Add expects a 3D point-> where can i see this on objects, that it expects 3D point ?
Can't find what you're looking for? Ask the community or share your knowledge.