Automatically adding bend notes - IV2010

Automatically adding bend notes - IV2010

Anonymous
Not applicable
6,396 Views
31 Replies
Message 1 of 32

Automatically adding bend notes - IV2010

Anonymous
Not applicable
I was looking at the possibility of automatically adding bend notes to a drawing of a sheet metal flat pattern.

Clearly I need to iterate through the bend lines on the drawing but I can't seem to find how to identify them.

Any help would be appreciated.
Accepted solutions (4)
6,397 Views
31 Replies
Replies (31)
Message 2 of 32

alewer
Advocate
Advocate
Accepted solution
To get the bend lines with VB.NET:

...
{code}
Dim oBendCollection As New Collection
For Each oView As Inventor.DrawingView In Sheet.DrawingViews
For Each oCurve As Inventor.DrawingCurve In oView.DrawingCurves
If oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendDownEdge Or oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendUpEdge Then
oBendCollection.Add(oCurve)
End If
Next oCurve
Next oView
{code}...
Message 3 of 32

Anonymous
Not applicable
Thanks for the guidance

Code now written :) Edited by: petercharles on Apr 25, 2010 12:46 PM
Message 4 of 32

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Working iLogic version:

 

Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oCurve As DrawingCurve
Dim oBendNote As BendNote

oDoc = ThisApplication.ActiveDocument
oSheet = oDoc.ActiveSheet

For Each oView In oSheet.DrawingViews
 For Each oCurve In oView.DrawingCurves
  If oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendDownEdge _
  Or oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendUpEdge Then
	' Create the bend note
	oBendNote = oSheet.DrawingNotes.BendNotes.Add(oCurve)
  End If
 Next 'oCurve
Next 'oView
Message 5 of 32

anilkumar279
Enthusiast
Enthusiast

Hi, ilogic rule is running fine. But one big issue is it re write the note.

 

If we already have one flat pattern view having bend notes and we have to add another flat pattern view. then if we run this rule then this rule repeat the bend note on already existing. 

Message 6 of 32

Anonymous
Not applicable

Hi this code is breaking for me at

Dim oBendNote As BendNote

error reads BendNote Type not defined

 

I am running Inventor 2009 is that the issue?

 

thanks

0 Likes
Message 7 of 32

BDCollett
Advisor
Advisor

@Curtis_Waguespack wrote:

Working iLogic version:

 

Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oCurve As DrawingCurve
Dim oBendNote As BendNote

oDoc = ThisApplication.ActiveDocument
oSheet = oDoc.ActiveSheet

For Each oView In oSheet.DrawingViews
 For Each oCurve In oView.DrawingCurves
  If oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendDownEdge _
  Or oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendUpEdge Then
	' Create the bend note
	oBendNote = oSheet.DrawingNotes.BendNotes.Add(oCurve)
  End If
 Next 'oCurve
Next 'oView

Does anyone know how to add to this code so that it checks a note already exists and doesn't add another?

Message 8 of 32

theo.bot
Collaborator
Collaborator
Accepted solution

@BDCollett 

 

I'm not sure if this is the most elegant way of checking te curves, but it works.

 

I added a check to compare the curve to the curves of the existing bendnotes.

 

Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oCurve As DrawingCurve
Dim oBendNote As BendNote
Dim oBendNoteExist As Boolean

oDoc = ThisApplication.ActiveDocument
oSheet = oDoc.ActiveSheet

For Each oView In oSheet.DrawingViews
 For Each oCurve In oView.DrawingCurves
  If oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendDownEdge _
  Or oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendUpEdge Then
  	oExist = False
	For Each oBendNote In oSheet.DrawingNotes.BendNotes
		 If oCurve.StartPoint.IsEqualTo(oBendNote.BendEdge.StartPoint) _
			 And oCurve.MidPoint.IsEqualTo(oBendNote.BendEdge.MidPoint) _
			 And oCurve.EndPoint.IsEqualTo(oBendNote.BendEdge.EndPoint) Then
			 	oBendNoteExist = True
			 	Exit For
		 End If
	Next

		' Create the bend note
		If oBendNoteExist = False Then
			oBendNote = oSheet.DrawingNotes.BendNotes.Add(oCurve)
		End If
  End If
 Next 'oCurve
Next 'oView
Message 9 of 32

BDCollett
Advisor
Advisor

@theo.bot wrote:

@BDCollett 

 

I'm not sure if this is the most elegant way of checking te curves, but it works.

 

I added a check to compare the curve to the curves of the existing bendnotes.

 

Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oCurve As DrawingCurve
Dim oBendNote As BendNote
Dim oBendNoteExist As Boolean

oDoc = ThisApplication.ActiveDocument
oSheet = oDoc.ActiveSheet

For Each oView In oSheet.DrawingViews
 For Each oCurve In oView.DrawingCurves
  If oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendDownEdge _
  Or oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendUpEdge Then
  	oExist = False
	For Each oBendNote In oSheet.DrawingNotes.BendNotes
		 If oCurve.StartPoint.IsEqualTo(oBendNote.BendEdge.StartPoint) _
			 And oCurve.MidPoint.IsEqualTo(oBendNote.BendEdge.MidPoint) _
			 And oCurve.EndPoint.IsEqualTo(oBendNote.BendEdge.EndPoint) Then
			 	oBendNoteExist = True
			 	Exit For
		 End If
	Next

		' Create the bend note
		If oBendNoteExist = False Then
			oBendNote = oSheet.DrawingNotes.BendNotes.Add(oCurve)
		End If
  End If
 Next 'oCurve
Next 'oView

Thanks for doing that. I actually found the solution in the other thread I replied to above this one which seemed to work. I am trying to combine this with a rule that replaces the text on the bend note at the same time now. I have the two separate rules working but not as one.

Message 10 of 32

theo.bot
Collaborator
Collaborator

@BDCollett  this works



Sub
Main Dim oDoc As DrawingDocument Dim oSheet As Sheet Dim oView As DrawingView Dim oCurve As DrawingCurve Dim oBendNote As BendNote Dim oBendNoteExist As Boolean oDoc = ThisApplication.ActiveDocument oSheet = oDoc.ActiveSheet For Each oView In oSheet.DrawingViews For Each oCurve In oView.DrawingCurves If oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendDownEdge _ Or oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendUpEdge Then oBendNoteExist = False For Each oBendNote In oSheet.DrawingNotes.BendNotes If oCurve.StartPoint.IsEqualTo(oBendNote.BendEdge.StartPoint) _ And oCurve.MidPoint.IsEqualTo(oBendNote.BendEdge.MidPoint) _ And oCurve.EndPoint.IsEqualTo(oBendNote.BendEdge.EndPoint) Then oBendNoteExist = True Call ChangeText(oBendNote) Exit For End If Next ' Create the bend note If oBendNoteExist = False Then oBendNote = oSheet.DrawingNotes.BendNotes.Add(oCurve) Call ChangeText(oBendNote) End If End If Next 'oCurve Next 'oView End Sub Sub ChangeText( oNote As BendNote) 'clear overrides (if any) oNote.HideValue = False oNote.Text = "" 'check direction and set note If oNote.Text.Contains("DOWN") Then oText = Replace(oNote.Text,"DOWN","Baixo") oNote.Hidevalue = True oNote.Text = oText End If If oNote.Text.Contains("UP") Then oText = Replace(oNote.Text,"UP","Cima") oNote.Hidevalue = True oNote.Text = oText End If End Sub

 

Message 11 of 32

BDCollett
Advisor
Advisor

@theo.bot wrote:

@BDCollett  this works


 


Hey @theo_bot that's really nice and very close thank you!

The only thing that was nice in one of the other rules was that it would also loop through the sheets and apply the rule as sometimes the flat pattern may not be on the front sheet and when the rule is automatically triggered it doesn't apply to any but the first sheet.

 

'loop through sheets
For Each oSheet In oDoc.Sheets
	oSheet.Activate
	'loop through bend notes
	For Each oNote In oSheet.DrawingNotes.BendNotes

 

0 Likes
Message 12 of 32

BDCollett
Advisor
Advisor

If I set it to trigger it seems to update multiple sheets.

Message 13 of 32

Stakin
Collaborator
Collaborator

i meet the same problem of it ,wonderful to solve it.

0 Likes
Message 14 of 32

theo.bot
Collaborator
Collaborator

@BDCollett 

 

The original code was for the active sheet. I don't use multi sheet drawings so i didn't pay attentions to that ;-).

So if you use multiple sheets you can change the oSheet definition from a fixed one to one of the sheets collection. so you need a new "for each" statement. in the beginning.

 

I have update the code a little bit so it now loops thru the sheets. I also put a check in the views loop, because only flatpatternviews contains bendlines ("If oView.IsFlatPatternView Then"). So we can skip all other views.

Sub Main

Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oCurve As DrawingCurve
Dim oBendNote As BendNote
Dim oBendNoteExist As Boolean

oDoc = ThisApplication.ActiveDocument

For Each oSheet In oDoc.Sheets
	For Each oView In oSheet.DrawingViews
		'check if view is Flatpattern
		If oView.IsFlatPatternView Then
			' Find Bend lines
			For Each oCurve In oView.DrawingCurves
				If oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendDownEdge _
				Or oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendUpEdge Then
				oBendNoteExist = False
					For Each oBendNote In oSheet.DrawingNotes.BendNotes
						If oCurve.StartPoint.IsEqualTo(oBendNote.BendEdge.StartPoint) _
						And oCurve.MidPoint.IsEqualTo(oBendNote.BendEdge.MidPoint) _
						And oCurve.EndPoint.IsEqualTo(oBendNote.BendEdge.EndPoint) Then
						oBendNoteExist = True
							Call ChangeText(oBendNote)
							Exit For
						End If
					Next

					' Create the bend note
					If oBendNoteExist = False Then
					oBendNote = oSheet.DrawingNotes.BendNotes.Add(oCurve)
					Call ChangeText(oBendNote)
					End If
				End If
			Next 'oCurve
		End If
	Next 'oView
Next 'osheet
InventorVb.DocumentUpdate()

End Sub
Sub ChangeText( oNote As BendNote)
'clear overrides (if any)
		oNote.Hidevalue = False
		oNote.Text = ""
		'check direction and set note
		If oNote.Text.Contains("DOWN") Then
			oText = Replace(oNote.Text,"DOWN","Baixo")
			oNote.Hidevalue = True
			oNote.Text = oText
		End If
		If oNote.Text.Contains("UP") Then
			oText = Replace(oNote.Text,"UP","Cima")
			oNote.Hidevalue = True
			oNote.Text = oText
		End If
		
	End Sub

 

Message 15 of 32

BDCollett
Advisor
Advisor

@theo.bot wrote:

@BDCollett 

 

The original code was for the active sheet. I don't use multi sheet drawings so i didn't pay attentions to that ;-).

So if you use multiple sheets you can change the oSheet definition from a fixed one to one of the sheets collection. so you need a new "for each" statement. in the beginning.

 

I have update the code a little bit so it now loops thru the sheets. I also put a check in the views loop, because only flatpatternviews contains bendlines ("If oView.IsFlatPatternView Then"). So we can skip all other views.

 


Legend! That seems to work quite well. Thank you for your replies.

The "on save" trigger updates all sheets. The "After Open Document" trigger seems to only work on the current sheet. I am unsure why that is. I am just trying to test different workflows. If the model was changed and if the drawing is then getting those updates pushed through due to the overridden bendline text. If the iLogic doesn't trigger there is a risk the text is wrong. 

0 Likes
Message 16 of 32

theo.bot
Collaborator
Collaborator

Here is the full list of events with explanations: Inventor 2022 Help | Event Trigger Reference | Autodesk

 

I would set the rule to the trigger "before Save Document", because this ensures your document is updated when saved. Espcialy if you would use other rules to create export etc or checking your file into Vault.

Optional you can also use trigger "Drawing view change" ensuring that when you make modifications to your part your drawingview updates automaticly on return to your drawing.

 

theobot_0-1633427345860.png

 

0 Likes
Message 17 of 32

BDCollett
Advisor
Advisor

@theo.bot wrote:

Here is the full list of events with explanations: Inventor 2022 Help | Event Trigger Reference | Autodesk

 

I would set the rule to the trigger "before Save Document", because this ensures your document is updated when saved. Espcialy if you would use other rules to create export etc or checking your file into Vault.

Optional you can also use trigger "Drawing view change" ensuring that when you make modifications to your part your drawingview updates automaticly on return to your drawing.

 

theobot_0-1633427345860.png

 


I did check the "drawing view change" trigger and that was not updating all the sheets either when returning to the drawing.

0 Likes
Message 18 of 32

BDCollett
Advisor
Advisor

@theo.bot

 

I added extra code at the end to remove the degree symbol as well and it causes something strange.

 

If oNote.Text.Contains("°") Then
			oText = Replace(oNote.Text,"°","")
			oNote.HideValue = True
			oNote.Text = oText
		End If

For some reason it turns on some text:

 

BDCollett_1-1634679698166.png

BDCollett_0-1634679667874.png

 

Adding some more code to remove the \Q works but I can't workout why it does this. Any ideas?

 

0 Likes
Message 19 of 32

theo.bot
Collaborator
Collaborator

I've changed my code to do the same but i can't reproduce your issue. Can you share a sample model and your code.

 

here's my updated version:

 

Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oCurve As DrawingCurve
Dim oBendNote As BendNote
Dim oBendNoteExist As Boolean

oDoc = ThisApplication.ActiveDocument

For Each oSheet In oDoc.Sheets
	For Each oView In oSheet.DrawingViews
		'check if view is Flatpattern
		If oView.IsFlatPatternView Then
			' Find Bend lines
			For Each oCurve In oView.DrawingCurves
				If oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendDownEdge _
				Or oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendUpEdge Then
				oBendNoteExist = False
					For Each oBendNote In oSheet.DrawingNotes.BendNotes
						If oCurve.StartPoint.IsEqualTo(oBendNote.BendEdge.StartPoint) _
						And oCurve.MidPoint.IsEqualTo(oBendNote.BendEdge.MidPoint) _
						And oCurve.EndPoint.IsEqualTo(oBendNote.BendEdge.EndPoint) Then
						oBendNoteExist = True
							Call ChangeText(oBendNote)
							Exit For
						End If
					Next

					' Create the bend note
					If oBendNoteExist = False Then
					oBendNote = oSheet.DrawingNotes.BendNotes.Add(oCurve)
					Call ChangeText(oBendNote)
					End If
				End If
			Next 'oCurve
		End If
	Next 'oView
Next 'osheet
InventorVb.DocumentUpdate()

End Sub
Sub ChangeText( oNote As BendNote)
'clear overrides (if any)
		oNote.Hidevalue = False
		oNote.Text = ""
		'check direction and set note
		If oNote.Text.Contains("DOWN") Then
			oText = Replace(oNote.Text, "DOWN", "Omlaag")
				If oText.Contains("°") Then
				oText = Replace(oText, "°", "")
				End If
			oNote.HideValue = True
			oNote.Text = oText
		End If
		If oNote.Text.Contains("UP") Then
			oText = Replace(oNote.Text, "UP", "Omhoog")
				If oText.Contains("°") Then
				oText = Replace(oText, "°", "")
				End If
			oNote.HideValue = True
			oNote.Text = oText
		End If
		
	End Sub

 

 

0 Likes
Message 20 of 32

BDCollett
Advisor
Advisor
Accepted solution

@theo.bot wrote:

I've changed my code to do the same but i can't reproduce your issue. Can you share a sample model and your code.

 

here's my updated version:

 

Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oCurve As DrawingCurve
Dim oBendNote As BendNote
Dim oBendNoteExist As Boolean

oDoc = ThisApplication.ActiveDocument

For Each oSheet In oDoc.Sheets
	For Each oView In oSheet.DrawingViews
		'check if view is Flatpattern
		If oView.IsFlatPatternView Then
			' Find Bend lines
			For Each oCurve In oView.DrawingCurves
				If oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendDownEdge _
				Or oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendUpEdge Then
				oBendNoteExist = False
					For Each oBendNote In oSheet.DrawingNotes.BendNotes
						If oCurve.StartPoint.IsEqualTo(oBendNote.BendEdge.StartPoint) _
						And oCurve.MidPoint.IsEqualTo(oBendNote.BendEdge.MidPoint) _
						And oCurve.EndPoint.IsEqualTo(oBendNote.BendEdge.EndPoint) Then
						oBendNoteExist = True
							Call ChangeText(oBendNote)
							Exit For
						End If
					Next

					' Create the bend note
					If oBendNoteExist = False Then
					oBendNote = oSheet.DrawingNotes.BendNotes.Add(oCurve)
					Call ChangeText(oBendNote)
					End If
				End If
			Next 'oCurve
		End If
	Next 'oView
Next 'osheet
InventorVb.DocumentUpdate()

End Sub
Sub ChangeText( oNote As BendNote)
'clear overrides (if any)
		oNote.Hidevalue = False
		oNote.Text = ""
		'check direction and set note
		If oNote.Text.Contains("DOWN") Then
			oText = Replace(oNote.Text, "DOWN", "Omlaag")
				If oText.Contains("°") Then
				oText = Replace(oText, "°", "")
				End If
			oNote.HideValue = True
			oNote.Text = oText
		End If
		If oNote.Text.Contains("UP") Then
			oText = Replace(oNote.Text, "UP", "Omhoog")
				If oText.Contains("°") Then
				oText = Replace(oText, "°", "")
				End If
			oNote.HideValue = True
			oNote.Text = oText
		End If
		
	End Sub

 

 


I will try the way you have done it and see if that fixes it. Thank you!

0 Likes