Insert iProperty to text field in Drawing

Insert iProperty to text field in Drawing

Anonymous
Not applicable
720 Views
2 Replies
Message 1 of 3

Insert iProperty to text field in Drawing

Anonymous
Not applicable

I may not be asking the right question but I can't find an answer. I want to be able to insert a live iProperty field into a note in a drawing via VBA or iLogic. For example if I manually create a note I have the option to insert a field for any associated parameter as well as model property which is live and updates with changes to those parameters. I want to be able to add the note and field via code, is this possible? I have spent several hours digging through the application project and I can get most of the values without issue but I can't seem to insert a field like I am able to do manually.

 

Any help is appreciated!

 

Thanks

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

Sergio.D.Suárez
Mentor
Mentor

Hi, Here is an example of how to attach a note to a view. In the note a property is captured, in this example the "partnumber".
This action is similar for all types of notes.

 

Dim sFont As String =  "ISOCPEUR"  ' "ISOCP_IV25"
Dim sFSize1 As Double = 0.3 'font size in cm 

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oActiveSheet As Sheet = oDoc.ActiveSheet

Try
		Line1 :
	' Set a reference to the drawing curve segment.
	' This assumes that a drawing curve is selected.
	Dim oDrawingCurveSegment As DrawingCurveSegment 
	oDrawingCurveSegment = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingDefaultFilter, "Select PartComponent")

	If oDrawingCurveSegment Is Nothing Then
		Exit Sub
	Else

	    ' Set a reference to the drawing curve.
	    Dim oDrawingCurve As DrawingCurve
	    oDrawingCurve = oDrawingCurveSegment.Parent

	    ' Get the mid point of the selected curve
	    ' assuming that the selected curve is linear
	    Dim oMidPoint As Point2d
	    oMidPoint = oDrawingCurve.MidPoint

	    ' Set a reference to the TransientGeometry object.
	    Dim oTG As TransientGeometry
	    oTG = ThisApplication.TransientGeometry

	    Dim oLeaderPoints As ObjectCollection
	    oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection

	    ' Create a few leader points.
	    Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 0.5, oMidPoint.Y - 0.5))
	    'Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 10, oMidPoint.Y + 5))

	    ' Create an intent and add to the leader points collection.
	    ' This is the geometry that the leader text will attach to.
	    Dim oGeometryIntent As GeometryIntent
	    oGeometryIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve)

	    Call oLeaderPoints.Add(oGeometryIntent)
		
		'oDescription ="<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Bold='True'><Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
		oPartNumber = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Bold='True'><Property Document='model' PropertySet='Design Tracking Properties' Property='PartNumber' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property></StyleOverride>"
		
	    ' Create text with simple string as input. Since this doesn't use
	    ' any text overrides, it will default to the active text style.
	    Dim sText As String = oPartNumber '<Br/> "Other text"

		Dim oLeaderNote As LeaderNote
	    oLeaderNote = oActiveSheet.DrawingNotes.LeaderNotes.Add(oLeaderPoints, sText)
	    oLeaderNote.VerticalJustification = 25601

	    ' Insert a node.
	    Dim oFirstNode As LeaderNode
	    oFirstNode = oLeaderNote.Leader.RootNode.ChildNodes.Item(1)

	    'Dim oSecondNode As LeaderNode
	    'oSecondNode = oFirstNode.ChildNodes.Item(1)

	End If
	GoTo Line1
Catch
End Try

 I hope this helps. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thank you for your response. This works but I have two more questions.

 

Assume that I have 2 assemblies on a drawing, one is for reference only and drawing purposes. How do I control which assembly or part I am pulling the parameter from? I don't see where oPartnumber is referenced back to a specific part/assembly?

 

I am trying to capture the mass property. The default unit is grams, can I change the unit output? I have tried several things but anything that I change causes it to drop in as text instead of a live parameter.

 

Last thing, when it drop in the parameter in the text field it appears as though there is an error. I have verified that the parameter is tied to the mass and updates but I expected to see <MASS>..

 

Thanks again!

 

 

0 Likes