Parameter is not linking in LeaderNote text in c#.

Parameter is not linking in LeaderNote text in c#.

Anonymous
Not applicable
542 Views
2 Replies
Message 1 of 3

Parameter is not linking in LeaderNote text in c#.

Anonymous
Not applicable

Hello All ,

                I hope you all are good . I am getting an issue i.e. parameter is not getting linked in leader note. I got vba code and I have converted it and used in c#. But parameter is not linking there. Please check the bellow code and let me know where I did wrong.

Issue of parameter linking..jpg

try{
ObjectCollection leaderPoints = invApp.TransientObjects.CreateObjectCollection();
Point2d notePoint1 = cm1.Position.Y < cm2.Position.Y ? cm1.Position : cm2.Position;

Point2d notePoint2 = cm1.Position;
notePoint2.X += notePoint1.X < baseView.Center.X ? -baseView.Width * 0.25 : baseView.Width * 0.25;
notePoint2.Y += drawingConstant.FontPlacementConstant * 5;
leaderPoints.Add(notePoint2);
leaderPoints.Add(notePoint1);

string Dia = FeatureParameterConstants.SlotDiameter ;
string holeDia = "<Parameter Resolved='True' ComponentIdentifier='" + drawingDoc.FullFileName + "' Name='" + Dia + "' Precision='0' ></Parameter>";

string Depth = FeatureParameterConstants.SlotDepth ;
string holeDepth = "<Parameter Resolved='True' ComponentIdentifier='" + drawingDoc.FullFileName + "' Name='" + redirectionDepth + "' Precision='0' ></Parameter>";

var holeNote = $"Slot{System.Environment.NewLine}{Dia} wide, {Depth} deep";
LeaderNote leaderNote = drawingDoc.ActiveSheet.DrawingNotes.LeaderNotes.Add(leaderPoints, "Temp");

leaderNote.FormattedText = holeNote;
}
catch (Exception Ex)
{
throw Ex;
}

 

 

 

Thanks in Advance ...!!

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

JhoelForshav
Mentor
Mentor

Hi @Anonymous 

I don't think you can use parameters from the actual drawing document in a formatted text. Maybe I'm wrong but I cannot find a way to do it manually which is a strong indication that I'm right 🙂

 

Because I assume your variable "drawingDoc" Is the actual drawing document?

 

You can however use parameters from any document that's referenced by the drawing. For example this iLogic rule will set the formatted text of a drawing note the user selects to the parameter Test from the document referenced by the drawings first view 🙂

Dim oNote As GeneralNote = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingNoteFilter, "Pick drawing note.")
Dim oDoc As Document = ThisDoc.Document.ActiveSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
oNote.FormattedText = "<Parameter ComponentIdentifier="+ "'"+ oDoc.FullDocumentName +"'" +" Name='Test' Precision='1'></Parameter>"
0 Likes
Message 3 of 3

WCrihfield
Mentor
Mentor

Here's a simple (iLogic / vb.net)  tool I often use to quickly understand what is needed to make a LeaderNote (or similar object) look the way I want it by code.

First I create a sample LeaderNote, and prepare it's contents the way I want it to look.

Then I use this code to pull all the special formatting code needed for it, so I can use that data to recreate the similar thing by code.

This basically this returns the contents of the FormattedText as selectable text, using the 'default response' portion of an InputBox.

 

Dim oLNote As LeaderNote = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingNoteFilter, "Select a leader note.")
InputBox("Here is the current contents of the FormattedText:", "FORMATTED TEXT",oLNote.FormattedText)

 

Also, for reference, here is the link to the online help page concerning FormattedText.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes