ADD INSTANCE PROPERTY IN LEADER NOTE FOR EACH BOM ITEM USING ILOGIC

ADD INSTANCE PROPERTY IN LEADER NOTE FOR EACH BOM ITEM USING ILOGIC

suresh.r.ext
Contributor Contributor
645 Views
5 Replies
Message 1 of 6

ADD INSTANCE PROPERTY IN LEADER NOTE FOR EACH BOM ITEM USING ILOGIC

suresh.r.ext
Contributor
Contributor

I like to create a tool which will automatically generate the leader note as attached snip. i have tried two methods.

 

1. by selecting the curves it will create the leader note with tag but it consider only part, not assembly.

2. iterating each bom item. but i cant able to select drawing curve for each bom item. 

 

i will drop my code for your reference, can somebody help me to provide me a ilogic code. ?

 

thanks in advance

0 Likes
Accepted solutions (1)
646 Views
5 Replies
Replies (5)
Message 2 of 6

daltonNYAW9
Advocate
Advocate

Hello,

 

Try adding this. It will keep trying to get either the instance property or change the occurrence to the "ParentOccurrence" until the occurrence = Nothing.

Do Until oOcc Is Nothing
	Try
		Dim prp As PropertySet = oOcc.OccurrencePropertySets.Item(1)
		MessageBox.Show(prp.Item("Tag").Value)
Exit Do Catch : End Try oOcc = oOcc.ParentOccurrence Loop

 

0 Likes
Message 3 of 6

suresh.r.ext
Contributor
Contributor
Hi Thanks , it solves my 1 problem. now i have to add the leader text as custom iproperties named <Tag> (selected drawing parentoccurence ) can you help with this ?
0 Likes
Message 4 of 6

daltonNYAW9
Advocate
Advocate
Accepted solution

I got this to work. Highlighted the parts in red I added.

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing Document must be active for this rule to work. Exiting.", vbOKOnly + vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oDCurve As DrawingCurveSegment
Dim prpname As String = "Tag"
Dim oDesc As String

RepeatProcess :
oDCurve = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select a DrawingCurveSegment.")
If oDCurve Is Nothing Then
	MsgBox("Nothing was selected. Exiting.")
	Exit Sub
End If
Dim oView As DrawingView = oDCurve.Parent.Parent

'check view doc's type first, then use that to determine edge type (Edge or EdgeProxy), and other stuff
Dim oDTProps As PropertySet
Dim oQty As Integer
Dim oPN As String
If oView.ReferencedDocumentDescriptor.ReferencedDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
	Dim oViewDoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
	Dim oEdge As EdgeProxy = oDCurve.Parent.ModelGeometry
	Dim oBody As SurfaceBodyProxy = oEdge.Parent

	Dim oOcc As ComponentOccurrence = oBody.Parent
	Dim prp As PropertySet = Nothing

	Do Until oOcc Is Nothing
		Try
			prp = oOcc.OccurrencePropertySets.Item(1)
			Exit Do
		Catch : End Try
		oOcc = oOcc.ParentOccurrence
	Loop

	If prp Is Nothing Then
		MessageBox.Show("No instance property exists")
		Exit Sub
	End If
	
	Dim oOccDoc As Document = oOcc.Definition.Document
	oDTProps = oOccDoc.PropertySets.Item("Design Tracking Properties")
	oPN = oDTProps.Item("Part Number").Value
	oQty = oViewDoc.ComponentDefinition.Occurrences.AllLeafOccurrences(oOcc.Definition).Count
	oDesc = prp.Item(prpname).Value
	
	
End If



'create a new LeaderNote attached to the selected geometry
Dim oGeomIntent As GeometryIntent = oSheet.CreateGeometryIntent(oDCurve.Parent, .5)
Dim oPt As Point2d = ThisApplication.TransientGeometry.CreatePoint2d((oView.Left + oView.Width), oView.Top)
Dim oLeaderPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
oLeaderPoints.Add(oPt)
oLeaderPoints.Add(oGeomIntent)
Dim oFText As String = oDesc & "<Br/>" & "Part No.  " & oPN & "<Br/>" & "Qty.  " & oQty
Dim oLNote As LeaderNote = oSheet.DrawingNotes.LeaderNotes.Add(oLeaderPoints, oFText)

oRepeat = MsgBox("Create another custom leader?", vbYesNo + vbQuestion, "REPEAT?")
If oRepeat = vbYes Then GoTo RepeatProcess

You might want to add a way to change the leader point when creating multiple leaders in a view so they arnt all stacked up on eachother.
 

0 Likes
Message 5 of 6

suresh.r.ext
Contributor
Contributor

I have struggled a lot to access the parent occurence.Thanks a lot. One more thing need to update that leader text paste only string value, instead of calling the properties like the attached image. Can you check the attached image and work on that formatted text like <Tag> & <Partnumber> & <Qty> that's all I want now.

0 Likes
Message 6 of 6

daltonNYAW9
Advocate
Advocate

I would just set it up the way you wanted then copy the ".FormattedText" value and add it to ur code. Btw the <Qty> value would have to be a custom iproperty/instance property. Sadly you cant access the BOM quantity value in a drawing text.

daltonNYAW9_0-1710876990838.png

Dim oDrawingNote As DrawingNote = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingNoteFilter, "Select Note")

myparam = InputBox("Prompt", "Title", oDrawingNote.FormattedText)

 

0 Likes