PunchToolFeature not displayed on multibody sheet metal part

PunchToolFeature not displayed on multibody sheet metal part

Allen_Hart
Advocate Advocate
296 Views
2 Replies
Message 1 of 3

PunchToolFeature not displayed on multibody sheet metal part

Allen_Hart
Advocate
Advocate

I have a simple sheet metal multi-body test part with two bodies. Each body has a sketch on one face containing only a SketchPoint. I have an external iLogic rule to add a PunchToolFeature by picking a SketchPoint. The rule does create the punch feature on both bodies but only displays on one of them. Why does it not display? And how do I make it display?

I can provide the ipt , ide, and rule if needed.

Thanks

Allen

Allen_Hart_0-1656073124370.png

 

0 Likes
297 Views
2 Replies
Replies (2)
Message 2 of 3

Allen_Hart
Advocate
Advocate

After posting I realize there's not much anyone can do without the files, Duh. So here they are. 

Allen

''' Add a sheet metal PunchToolFeature to selected SketchPoints.
''' Sketch(s) and Point(s) must already be present.

Sub Main()
	' Get the active sheet metal document and component definition.
	Dim oPartDoc As PartDocument
	Try
		oPartDoc = ThisApplication.ActiveDocument
	Catch 
		MessageBox.Show("A part document must be active.", "Error1")
		Exit Sub
	End Try
	If Not oPartDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"  Then
		MessageBox.Show("A sheet metal document must be open.", "Error2")
		Exit Sub
	End If
	
	' Create a feature definition object for a punch tool.
	Dim oSMDef As SheetMetalComponentDefinition = oPartDoc.ComponentDefinition
	Dim oSMFeatures As SheetMetalFeatures = oSMDef.Features

	Dim oFile As String = "C:\Users\Public\Documents\Autodesk\Inventor 2023\Catalog\Punches\obround.ide"
	Dim oiFeatureDef As iFeatureDefinition = oSMFeatures.PunchToolFeatures.CreateiFeatureDefinition(oFile)
	
	' Prompt user to select a sketch point.
	Dim oCmdMgr As CommandManager = ThisApplication.CommandManager
	Dim oSourcePoint As SketchPoint = oCmdMgr.Pick(SelectionFilterEnum.kSketchPointFilter, "Select SketchPoint for Obround")
	
	Dim oPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	Call oPoints.Add(oSourcePoint)
	
	' Create the iFeature.
	Dim oPunchTool As PunchToolFeature = oSMFeatures.PunchToolFeatures.Add(oPoints, oiFeatureDef)

	' Find and change an existing PunchToolFeature. Uses iLogic Functions.
	rowNumber = iFeature.FindRow(oPunchTool.Name, "PunchLength", "=", 0.375, "PunchWidth", "=", 0.188)
	iFeature.ChangeRow(oPunchTool.Name, rowNumber)
	
End Sub	'Main
0 Likes
Message 3 of 3

jhunt3Z5BG
Participant
Participant

I looked into your issue a little and I see the problem.

 

  • When running the program it goes through all the paces and add only punches to Solid Body 1
    • They are not part of solid body 2, this is why they show up in your model tree but not in both solids.

When inserting a punch manually the software automatically selected the correct solid body for me, but the code will only recognize the first solid body.

 

I can write code to select the body, but I am trying to figure how to select the body and have the punch put it on that body. Because the normal process of inserting a punch doesn't ask for this I am struggling on how fix this. I will research a little more later. 

 

 

jhunt3Z5BG_0-1662580264292.png

 

0 Likes