<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Failed to create Punch Feature in API ( Help ) in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/failed-to-create-punch-feature-in-api-help/m-p/6008358#M61231</link>
    <description>&lt;P&gt;Hi ! I resolved problem by myself.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jan 2016 09:21:31 GMT</pubDate>
    <dc:creator>SandmanINV</dc:creator>
    <dc:date>2016-01-27T09:21:31Z</dc:date>
    <item>
      <title>Failed to create Punch Feature in API ( Help )</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/failed-to-create-punch-feature-in-api-help/m-p/6004069#M61167</link>
      <description>&lt;P&gt;Hi Everybody.&lt;/P&gt;&lt;P&gt;I am trying to create a punch feature, but, i failed. Somebody help me about that.&lt;/P&gt;&lt;P&gt;Here is my &amp;nbsp;code folow API Help.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;PRE&gt;Option Explicit
Private Sub cmd_khoitao_Click()
'Tao part
Dim opart As PartDocument
Set opart = ThisApplication.Documents.Add(kPartDocumentObject, _
ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject, , , "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"))
'don vi do
'Dim ounit As UnitsOfMeasure
'Set ounit = ThisApplication.ActiveDocument.UnitsOfMeasure
'Dim olenghtunit As UnitsTypeEnum
'olenghtunit = ounit.LengthUnits
'unit.LengthUnits = kMillimeterLengthUnits
'ThisApplication.ActiveDocument.Update
'''''''''''''''
Dim ocompdef As SheetMetalComponentDefinition
Set ocompdef = opart.ComponentDefinition

Dim otransi As TransientGeometry
Set otransi = ThisApplication.TransientGeometry
'Quy dinh kich thuoc
ocompdef.UseSheetMetalStyleThickness = False
Dim othickness As Parameter
Set othickness = ocompdef.Thickness
othickness.Value = 0.16 'cm
'Tao base sketch
Dim osketchbase As Sketch
Set osketchbase = ocompdef.Sketches.Add(ocompdef.WorkPlanes.Item(2), False)

Dim orecbase As SketchEntitiesEnumerator
Set orecbase = osketchbase.SketchLines.AddAsTwoPointRectangle(otransi.CreatePoint2d(0, 0), otransi.CreatePoint2d(159.5, 104.9))
'Base feature
Dim obaseprofile As Profile
Set obaseprofile = osketchbase.Profiles.AddForSolid

Dim smfeatures As SheetMetalFeatures
Set smfeatures = ocompdef.Features

Dim obasefacedef As FaceFeatureDefinition
Set obasefacedef = smfeatures.FaceFeatures.CreateFaceFeatureDefinition(obaseprofile)

Dim obaseface As FaceFeature
Set obaseface = smfeatures.FaceFeatures.Add(obasefacedef)
'Tao sketch thu 2
Dim ofacesketch2 As Face
Set ofacesketch2 = obaseface.Faces.Item(5)
Dim osketch2 As Sketch
Set osketch2 = ocompdef.Sketches.AddWithOrientation(ofacesketch2, ocompdef.WorkAxes.Item(1), True, True, ocompdef.WorkPoints.Item(1), False)
Dim opointcol As ObjectCollection
Set opointcol = ThisApplication.TransientObjects.CreateObjectCollection

Dim opoint11 As SketchPoint
Set opoint11 = osketch2.SketchPoints.Add(otransi.CreatePoint2d(-159.5 + 24.72, 104.9 - 13.74), True)
Call opointcol.Add(opoint11)

Dim opoint12 As SketchPoint
Set opoint12 = osketch2.SketchPoints.Add(otransi.CreatePoint2d(-159.5 + 24.72 - 6, 104.9 - 13.74), True)
Call opointcol.Add(opoint12)

Dim opoint13 As SketchPoint
Set opoint13 = osketch2.SketchPoints.Add(otransi.CreatePoint2d(-159.5 + 24.72 - 12, 104.9 - 13.74), True)
Call opointcol.Add(opoint13)
'ifeature deffinition
Dim oiFeatureDef As iFeatureDefinition
Set oiFeatureDef = smfeatures.PunchToolFeatures.CreateiFeatureDefinition( _&lt;BR /&gt;"C:\Users\Public\Documents\Autodesk\Inventor 2015\Catalog\Punches\keyhole.ide")
' Set input
Dim oInput As iFeatureInput
For Each oInput In oiFeatureDef.iFeatureInputs
Dim oparainput As iFeatureParameterInput

Select Case oInput.Name
Case "Length"
Set oparainput = oInput
oparainput.Expression = "0.1 cm"

Case "Slot_Width"
Set oparainput = oInput
oparainput.Expression = "1.2 cm"

Case "Hole_Diameter"
Set oparainput = oInput
oparainput.Expression = "1.5 cm"

End Select
Next
Dim opunch1 As PunchToolFeature
Set opunch1 = smfeatures.PunchToolFeatures.Add(opointcol, oiFeatureDef)

MsgBox ("Done!")
ThisApplication.ActiveView.GoHome

End Sub&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jan 2016 07:47:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/failed-to-create-punch-feature-in-api-help/m-p/6004069#M61167</guid>
      <dc:creator>SandmanINV</dc:creator>
      <dc:date>2016-01-25T07:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to create Punch Feature in API ( Help )</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/failed-to-create-punch-feature-in-api-help/m-p/6006029#M61196</link>
      <description>&lt;P&gt;Somebody help.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 04:01:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/failed-to-create-punch-feature-in-api-help/m-p/6006029#M61196</guid>
      <dc:creator>SandmanINV</dc:creator>
      <dc:date>2016-01-26T04:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to create Punch Feature in API ( Help )</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/failed-to-create-punch-feature-in-api-help/m-p/6008358#M61231</link>
      <description>&lt;P&gt;Hi ! I resolved problem by myself.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2016 09:21:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/failed-to-create-punch-feature-in-api-help/m-p/6008358#M61231</guid>
      <dc:creator>SandmanINV</dc:creator>
      <dc:date>2016-01-27T09:21:31Z</dc:date>
    </item>
  </channel>
</rss>

