Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

multibody and Ipart generated seperately

1 REPLY 1
SOLVED
Reply
Message 1 of 2
halganabi
94 Views, 1 Reply

multibody and Ipart generated seperately

if I am having multibody and Ipart table,

I am requested to make these multibodies as separate part with naming (RE-P1, RE-P2,) for each sold body followed by the name of the ipart memeber, 
and then i shall go for each part and make flatsheet DXF 


Anyway to automate this: 
step1-each ipart memeber -> go through all of bodies -> make new component or part with new name [solid name - ipart memeber name]
step1- for each part -> generate flatsheet dxf. 

u can ignore step2 if find it hard at least step1

thanks

Screenshot 2023-09-26 111919.png

1 REPLY 1
Message 2 of 2
halganabi
in reply to: halganabi

it works great by this code 


Sub main()
ExcelF = "F:\OneDrive - MACT Group of Companies\Desktop\tests\16\Lo.xlsx"
Dim MMMax = CDbl(InputBox("Prompt", "Title", "Max"))
Parameter("d0") = 50



For i = 2 To MMMax	
	
Dim Name As String = GoExcel.CellValue(ExcelF, "SS", "A" & i)
Dim LL As String = GoExcel.CellValue(ExcelF, "SS", "B" & i)
Dim FF As String = GoExcel.CellValue(ExcelF, "SS", "C" & i)


Parameter("LLX") = LL
Parameter("FF1") = FF
MessageBox.Show(Name & ", " &LL & ", "& FF & ", ", "Title")
MessageBox.Show(ThisDoc.PathAndFileName(False), "Title")
InventorVb.DocumentUpdate()
ThisDoc.Document.SaveAs(ThisDoc.Path & "\"  & Name & ".ipt", True)

'---------------Make Components-----------------'
Dim f As String = ThisDoc.Path & "\"
  Dim doc As PartDocument
  doc = ThisApplication.ActiveDocument
  
     
     Dim sb As SurfaceBody
  For Each sb In doc.ComponentDefinition.SurfaceBodies '----------------------
    ' Create part for each body
      Dim prt As PartDocument
      prt = ThisApplication.Documents.Add(kPartDocumentObject,"C:\Users\Public\Documents\Autodesk\Inventor 2024\Templates\en-US\Metric\Sheet Metal (mm).ipt",True)

        Dim dpcs As DerivedPartComponents
       dpcs = prt.ComponentDefinition.ReferenceComponents.DerivedPartComponents
	   
	       Dim dpd As DerivedPartUniformScaleDef
           dpd = dpcs.CreateUniformScaleDef(doc.FullDocumentName)
		   
		   ' Exclude the other solid bodies
    Dim dpe As DerivedPartEntity
    For Each dpe In dpd.Solids     '----------------------
      If Not dpe.ReferencedEntity Is sb Then
        dpe.IncludeEntity = False
      End If
     Next
   
    Call dpcs.Add(dpd)
	Call prt.SaveAs(f & Name & " - " & sb.Name & ".ipt", False)
	
	
	Dim oDef As SheetMetalComponentDefinition = prt.ComponentDefinition
	Dim oPartMember As iPartMember
	Dim oFeat As PartFeature
	If oDef.HasFlatPattern = False Then
		oDef.Unfold
	Else
		oDef.FlatPattern.Edit
	End If
	Dim odxf As String
	Dim oPath As String

	oPath = ThisDoc.Path & "\DXF" 
	If Not System.IO.Directory.Exists(oPath) Then
		System.IO.Directory.CreateDirectory(oPath)
	End If
	Dim odxfname As String
	odxf = "FLAT PATTERN DXF?OuterProfileLayer=0&OuterProfileLayerColor=0;0;0&InteriorProfilesLayer=0&InteriorProfilesLayerColor=0;0;0&BendDownLayerLineType=37633&BendDownLayerColor=0;0;255&BendUpLayerLineType=37633&BendUpLayerColor=0;0;255&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_UNCONSUMED_SKETCHES;IV_BEND;IV_BEND_DOWN;IV_OUTER_PROFILE;IV_INTERIOR_PROFILES;IV_FEATURE_PROFILES;IV_FEATURE_PROFILES_DOWN;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_ROLL_TANGENT;IV_ROLL" _
		+ "&RebaseGeometry=True" _
		+ "&SimplifySplines=True" _
		+ "&SplineTolerance=0.01" _
		
	odxfname = oPath & "\" & ".dxf"
	oDef.DataIO.WriteDataToFile(odxf, odxfname)
	oDef.FlatPattern.ExitEdit
	
	Call prt.Close
	
	
  Next
'------------------------------------------------------------------------------
Next


End Sub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report