Add Parameter to Leader Text Crashing Inventor 2019

Add Parameter to Leader Text Crashing Inventor 2019

johnster100
Collaborator Collaborator
558 Views
9 Replies
Message 1 of 10

Add Parameter to Leader Text Crashing Inventor 2019

johnster100
Collaborator
Collaborator

Hi,

I'm trying to add a parameter to my leader text. The code works when i'm adding to a part file but fails when i'm adding it to an assembly occurrence.

 

To Simplify the problem i've writting the following code:

oDoc = ThisDoc.Document
Dim s As String
s = oDoc.ActiveSheet.DrawingNotes.LeaderNotes.Item(1).FormattedText
oDoc.ActiveSheet.DrawingNotes.LeaderNotes.Item(1).FormattedText = s

 

All this does is take the first leader, read in it's text, then sets it back to it's text. This works fine when the view is of a part file but crashes when using an assembly file.

 

I'm running Inventor 2019.4.8

 

I have attached the files and the ilogic rule is in the drawing,

any help is appreciated,

thanks,

John

0 Likes
559 Views
9 Replies
Replies (9)
Message 2 of 10

johnster100
Collaborator
Collaborator

any help available on this?

 

thanks again,

john

0 Likes
Message 3 of 10

JhoelForshav
Mentor
Mentor

Hi @johnster100 

I tried your files and "unfortunately" I can't reproduce the error in Inventor 2020 😞

0 Likes
Message 4 of 10

johnster100
Collaborator
Collaborator

yes I have since noticed that too. My issue is i'm stuck on inventor 2019 just now.

 

I was wondering if there is another way to update that property?

 

thanks,

John

0 Likes
Message 5 of 10

bradeneuropeArthur
Mentor
Mentor

could you upload the code for me, since i am using IV 2018?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 6 of 10

johnster100
Collaborator
Collaborator
oDoc = ThisDoc.Document
Dim s As String
s = oDoc.ActiveSheet.DrawingNotes.LeaderNotes.Item(1).FormattedText
oDoc.ActiveSheet.DrawingNotes.LeaderNotes.Item(1).FormattedText = s

 

The code is shown above. The drawing needs to be of an assembly file and the leader contains a parameter from a part file in the assembly.

 

I would create this for you myself but I don't have inventor 2018 on my computer 😞

 

Thanks,

John

0 Likes
Message 7 of 10

bradeneuropeArthur
Mentor
Mentor
Dim D As Inventor.DrawingDocument
D = ThisDoc.Document


Dim a As Inventor.Sheet
a = D.ActiveSheet

Dim Le As Inventor.LeaderNote
Le = a.DrawingNotes.LeaderNotes.Item(1)

Dim s As String
s = Le.FormattedText

MsgBox(s)
Le.FormattedText = s
MsgBox(Le.FormattedText)

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 8 of 10

johnster100
Collaborator
Collaborator

Hi,

thanks for the reply,

I still get an error with this new code.

Maybe it's specific to Inventor 2019?

 

As I said above the code works fine when the view is of a part file, it only crashes when it's an assembly file.

 

thanks,

John

 

 

0 Likes
Message 9 of 10

JhoelForshav
Mentor
Mentor

@johnster100 

I'm just guessing here but maybe the component path of the formatted text is not valid anymore?

Maybe the "Resolved= True" portion of the code causes some issues?

Maybe the component isn't open in inventors memory and that causes the problem?

 

Does this work?

 

oDoc = ThisDoc.Document
Dim s As String
s = oDoc.ActiveSheet.DrawingNotes.LeaderNotes.Item(1).FormattedText
'MsgBox(s)

Dim oComponent = s.Split({"ComponentIdentifier=" }, 2, StringSplitOptions.RemoveEmptyEntries)(1).Split({" Name=" }, 2, StringSplitOptions.RemoveEmptyEntries)(0)

Dim oName = s.Split({"Name="}, 2, StringSplitOptions.RemoveEmptyEntries)(1).Split({" Precision="}, 2, StringSplitOptions.RemoveEmptyEntries)(0)
Dim oPrecision = s.Split({"Precision="}, 2, StringSplitOptions.RemoveEmptyEntries)(1).Split({">"}, 2, StringSplitOptions.RemoveEmptyEntries)(0)
'MsgBox(oComponent) 'Use see to inspect that the component path is correct
'MsgBox(oName) 'Use this to see that the parameter name is correct
'MsgBox(oPrecision) 'Use this to see that the precision is correct

'Make sure the component is open in memory
ThisApplication.Documents.Open(oComponent.Replace("'", ""), False)

Dim oNewText As String = "<Parameter ComponentIdentifier=" & oComponent & " Name=" & oName & " Precision=" & oPrecision & " ></Parameter>"
MsgBox(oNewText)

oDoc.ActiveSheet.DrawingNotes.LeaderNotes.Item(1).FormattedText = oNewText
0 Likes
Message 10 of 10

johnster100
Collaborator
Collaborator

it's still not working 😞

 

I think someone from Autodesk will need to Investigate and explain the error. 

 

The fact that it works fine in 2020 makes me think it might be a bug in the 2019 😞

 

thanks for your time,

John

0 Likes