Edit TitleBlock Definition

Edit TitleBlock Definition

Anonymous
Not applicable
2,294 Views
21 Replies
Message 1 of 22

Edit TitleBlock Definition

Anonymous
Not applicable

Hi!

I'm currently editing titleblock definitions in .IDW files.

For some drawing documents, using the Definition.Edit() method leads to a crash (E_FAIL exception, System.RuntimeType.ForwardCallToInvokeMember problem).

 

The code I use is pretty straightforward so I guess there's something missing:

 

// sheet is active
var t = sheet.TitleBlock.Definition;

// t is not null 
// this call crashes sometimes againt some documents.
t.Edit(out DrawingSketch s);

What am I missing? What should I check before trying to edit the definition?

 

Thanks in advance for your help.

0 Likes
2,295 Views
21 Replies
Replies (21)
Message 21 of 22

WCrihfield
Mentor
Mentor

Sure sounds like a 'fun' project there. 😉  I assume you have some Reference(s)/Imports called out somewhere that allows you to access and use XML document specific functionality.  I honestly haven't explored into that area yet, because I simply haven't had a need to, but it certainly seems like something that might be worthwhile, since Inventor uses XML files for a lot of things.  So, since I can't follow all of what that code is doing, I'm afraid I wouldn't be much help in debugging any possible issues within that right now.  Was there anything remotely useful within the exception that it was throwing that might tell us specifically where the error is occurring, or what it was trying to do when the error occurred?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 22 of 22

MICHAEL.JONES.AMCE
Advocate
Advocate

Attached the start of the detailed report below.

 

Yes, we import the System.XML  library for the XML parsing. 

 

 

System.Runtime.InteropServices.COMException
  HResult=0x80004005
  Message=Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
  Source=mscorlib
  StackTrace:
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at Inventor.TextBox.set_FormattedText(String )
   at LibertyTitleBlockUpdate.Main.UpdateTitleBlock(TitleBlockDefinition tbDef) in C:\Users\msjones.AMCE\source\repos\LibertyTitleBlockUpdate\LibertyTitleBlockUpdate\Main.vb:line 190

 

 

Screen snippet showing line 190.

 

MICHAELJONESAMCE_0-1641414476525.png

 

The code originated from my VBA test code, which ran w/o an exception error.

 

I'm sure I'm missing something simple.

 

Watch shows that the CheckTxt has had it's values updated for the custom Iprop

 

MICHAELJONESAMCE_1-1641414800018.png

...and I just realized that perhaps the problem lies with the Replace statement perhaps there is not any VBcrLf when converting the XML element back to a string.

 

Nope that was not where the exception was being thrown.

 

MICHAELJONESAMCE_2-1641415125167.png

 

MICHAELJONESAMCE_3-1641415165641.png

When converting back from the Xelement the single quotes become double quotes. 

 

Wonder if the double quotes are causing the exception to be thrown?

 

Getting closer.

 

 

 

 

 

 

 

M.

0 Likes