I don't think the suggestion from Nedeljko will help here, CreateMember will just generate a member file corresponding to the specified row, which is not what you are looking for if I understand correctly the question.
You need to edit programmatically the iPart table, which is not doable directly from the available API but you can do it by editing the embedded Excel document that defines the table.
Below are VBA examples that illustrates how to dump content of the table and create a basic iPart from scratch. What you need to do is to edit a row of the table as you would wish from the UI and observe the syntax, so you can reproduce it from API:
Public Sub DumpiPartTable()
Dim doc As PartDocument
Set doc = ThisApplication.ActiveDocument
If (Not doc.ComponentDefinition.IsiPartFactory) Then Exit Sub
Dim factory As iPartFactory
Set factory = doc.ComponentDefinition.iPartFactory
Dim ws As Variant 'WorkSheet
Set ws = factory.ExcelWorkSheet
Dim rowIdx As Integer
Dim colIdx As Integer
For rowIdx = 1 To factory.TableRows.count + 1
Debug.Print "-------------------------------------------------"
For colIdx = 1 To factory.TableColumns.count
Debug.Print "Cell[" & rowIdx & "," & colIdx & "]: " & _
ws.Cells(rowIdx, colIdx).text
Next
Next
End Sub
Public Sub DumpiAssemblyTable()
Dim doc As AssemblyDocument
Set doc = ThisApplication.ActiveDocument
If (Not doc.ComponentDefinition.IsiAssemblyFactory) Then
Exit Sub
End If
Dim factory As iAssemblyFactory
Set factory = doc.ComponentDefinition.iAssemblyFactory
Dim ws As Variant ' WorkSheet
Set ws = factory.ExcelWorkSheet
Dim rowIdx As Integer
Dim colIdx As Integer
For rowIdx = 1 To factory.TableRows.count + 1
Debug.Print "-------------------------------------------------"
For colIdx = 1 To factory.TableColumns.count
Debug.Print "Cell[" & rowIdx & "," & colIdx & "]: " & _
ws.Cells(rowIdx, colIdx).text
Next
Next
End Sub
Public Sub CreateiPart()
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject), _
True)
oPartDoc.SaveAs "c:\Temp\APIiPart.ipt", False
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
Dim oCompDef As PartComponentDefinition
Set oCompDef = oPartDoc.ComponentDefinition
Dim oPoints(3) As point2d
Set oPoints(0) = oTG.CreatePoint2d(0, 0)
Set oPoints(1) = oTG.CreatePoint2d(5, 0)
Set oPoints(2) = oTG.CreatePoint2d(5, 5)
Set oPoints(3) = oTG.CreatePoint2d(0, 5)
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(1))
Dim oLines(3) As SketchLine
Set oLines(0) = oSketch.SketchLines.AddByTwoPoints( _
oPoints(0), oPoints(1))
Set oLines(1) = oSketch.SketchLines.AddByTwoPoints( _
oLines(0).EndSketchPoint, oPoints(2))
Set oLines(2) = oSketch.SketchLines.AddByTwoPoints( _
oLines(1).EndSketchPoint, oPoints(3))
Set oLines(3) = oSketch.SketchLines.AddByTwoPoints( _
oLines(2).EndSketchPoint, oLines(0).StartSketchPoint)
Dim oProfile As profile
Set oProfile = oSketch.Profiles.AddForSolid
Dim oExtrude As ExtrudeFeature
Set oExtrude = _
oCompDef.features.ExtrudeFeatures.AddByDistanceExtent( _
oProfile, 15, kPositiveExtentDirection, kNewBodyOperation, 0)
oExtrude.FeatureDimensions(1).parameter.Name = "Length"
oExtrude.FeatureDimensions(2).parameter.Name = "TaperAngle"
Dim oFactory As iPartFactory
Set oFactory = oCompDef.CreateFactory
Dim oWS As WorkSheet
Set oWS = oFactory.ExcelWorkSheet
oWS.Cells(1, 1) = "Member<defaultRow>1</defaultRow><filename></filename>"
oWS.Cells(1, 2) = "Part Number [Project]"
oWS.Cells(1, 3) = "Length<free>150 mm</free>"
oWS.Cells(1, 4) = "TaperAngle"
oWS.Cells(2, 1) = "APIiPart-01"
oWS.Cells(2, 2) = "APIiPart-01"
oWS.Cells(2, 3) = "150 mm"
oWS.Cells(2, 4) = "0 deg"
oWS.Cells(3, 1) = "APIiPart-02"
oWS.Cells(3, 2) = "APIiPart-02"
oWS.Cells(3, 3) = "100 mm"
oWS.Cells(3, 4) = "5 deg"
oWS.Cells(4, 1) = "APIiPart-03"
oWS.Cells(4, 2) = "APIiPart-03"
oWS.Cells(4, 3) = "50 mm"
oWS.Cells(4, 4) = "10 deg"
Dim oWB As workbook
Set oWB = oWS.Parent
oWB.Save
oWB.Close
oPartDoc.Update
oPartDoc.Save
End Sub
Take care not to mess up with the table as you could corrupt the document.
Hope that helps,
Philippe.
______________________________________________________________
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
Philippe Leefsma
Developer Technical Services
Autodesk Developer Network