Create a LeaderNote with Sheetmetal Thickness fails

Create a LeaderNote with Sheetmetal Thickness fails

bshbsh
Collaborator Collaborator
704 Views
8 Replies
Message 1 of 9

Create a LeaderNote with Sheetmetal Thickness fails

bshbsh
Collaborator
Collaborator

Hello,

I've been using this macro since a long time, but since changing to IV2018 it fails with Invalid Procedure call 5.

Dim Thk As Parameter
Set Thk = DrawingView.ReferencedDocumentDescriptor.ReferencedDocument.ComponentDefinition.Thickness
Dim Txt As String
Txt = "t=<Parameter Resolved='True' ComponentIdentifier='" & Thk.Parent.File.FullFileName & "' Name='" & Thk.Name & "' Precision='0'></Parameter> mm"
Set FLText = InvDoc.ActiveSheet.DrawingNotes.LeaderNotes.Add(LeaderPointsColl, Txt)

The LeaderPointsCollection is fine, if I create a leader with just a standard text, it works fine. So there's gotta be something with the Txt. But if I create the leadernote by hand, using the Parameter etc, then compare its formattedtext to the Txt variable (as the supposed formattedtext), they are the same thing.

What could be the problem?

0 Likes
705 Views
8 Replies
Replies (8)
Message 2 of 9

HermJan.Otterman
Advisor
Advisor

it is the text, replace it with "Hello" and it works.

 

what should the text say?

 

it is in the last part of the line..  "' Precision='0'></Parameter> mm"

 

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 3 of 9

bshbsh
Collaborator
Collaborator

It should say, "t=Xmm" where X is the thickness parameter of the sheetmetal.

What's wrong with the last part? It's been working fine like that before IV2018. When I create the leader by hand, it has the same formattedtext with the precision etc.

0 Likes
Message 4 of 9

HermJan.Otterman
Advisor
Advisor

ok, try this

 

Txt = "t=" & Thk.Value & "mm"

 

it should work

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 5 of 9

bshbsh
Collaborator
Collaborator

Wouldn't that be just a plain, static, non-adaptive text?

I figured out, if I create the leadernote with a static text first, then put any character after the <precision='0'> and the </parameter>, and then apply that as the new formattedtext, then it works. Strange. How did this work before?

Dim Thk As Parameter
Set Thk = DrawingView.ReferencedDocumentDescriptor.ReferencedDocument.ComponentDefinition.Thickness Dim FLText As LeaderNote Set FLText = InvDoc.ActiveSheet.DrawingNotes.LeaderNotes.Add(LeaderPointsColl, "t=Xmm") Dim Txt As String If Abs(Thk.Value - (Round(10 * Thk.Value) / 10)) < 0.01 Then Txt = "t=<Parameter Resolved='True' ComponentIdentifier='" & Thk.Parent.FullFileName & "' Name='" & Thk.Name & "' Precision='0'>X</Parameter>mm" Else Txt = "t=<Parameter Resolved='True' ComponentIdentifier='" & Thk.Parent.FullFileName & "' Name='" & Thk.Name & "' Precision='1'>X</Parameter>mm" End If FLText.FormattedText = Txt
Message 6 of 9

HermJan.Otterman
Advisor
Advisor

what version of Inventor are you using?

 

the lines don't work with me...

 

sorry, it work for me too!!, great!!

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 7 of 9

bshbsh
Collaborator
Collaborator

2018.2.3. and that is obviously not the entire code .Smiley Wink

0 Likes
Message 8 of 9

marcin_otręba
Advisor
Advisor

place your leader manually then use:

 

Dim draw As DrawingDocument
Set draw = ThisApplication.ActiveDocument
Dim fltext As LeaderNote
Set fltext = draw.ActiveSheet.DrawingNotes.Item(1)
Debug.Print fltext.FormattedText

 

it will print your formatted string

 then

 

copy/paste it to your code  in Txt=

 

 

i assumed that your thickness is exported as property in ipt file and you will use it ?

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 9 of 9

bshbsh
Collaborator
Collaborator

Resurrection...

There's another problem with this code. If the sheetmetal part is a derived component of another sheetmetal part (usually a mirrored version), with the sheetmetal parameters and sheetmetal styles linked, then the code throws an error when trying to modify the leadernote text to have the thickness parameter in it.

And I can't figure out why. It's gotta be the fact that there are reference parameters involved. However, the SheetMetalCompDef.Thickness resolves to a modelparameter and not to a reference parameter, and the actual thickness parameter doesn't seem to be linked to or driven by any of the referenced parameters at all.

I belive the componentidentifier here

<Parameter Resolved='True' ComponentIdentifier=...> 

 would have to point to the referenced file maybe? (Haven't tried it yíet.) But why?

And how do I determine if that is the case, because checking the thickness parameter does not give any clue: it's a modelparameter not a referenceparameter, and it is not in the list of referenceparameter objects either.

Any ideas? Thanks.

0 Likes