Replacing text in a drawing

Replacing text in a drawing

pavol_krasnansky
Enthusiast Enthusiast
1,919 Views
7 Replies
Message 1 of 8

Replacing text in a drawing

pavol_krasnansky
Enthusiast
Enthusiast

Hello. I need to create a rule for to translate a drawing. I have a translate table in the Microsoft Excel (Slovak / English). According to this table I need to replace the texts in the drawing. Text can be in all objects in a sheet. I tried this rule:
https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/find-and-replace-text-for-active-she...
Replace text does not work in SketchedSymbols. I don't know why.
Is possible to replace text also in BOM and in a dimensions?
Thank you.

0 Likes
Accepted solutions (1)
1,920 Views
7 Replies
Replies (7)
Message 2 of 8

WCrihfield
Mentor
Mentor

Hi @pavol_krasnansky.  One thing I see right away in my code at that link, is that it needs to define the TextBox variable's Type more specifically.  When you just specify TextBox as the variable's Type, it can get confused and think it is a System.Windows.Forms.TextBox Type object, instead of an 'Inventor.TextBox' Type object.  That is a common mistake that can be difficult to diagnose unless you pay attention to the 'Intellisense' suggestions that pop-up when you hover over the variable, or the Type declaration.

So, to fix that possible/potential problem, simply use this:

Dim oTextBox As Inventor.TextBox

...instead of this:

Dim oTextBox As TextBox

I will have to look into the other requested capabilities, and see what I can come up with...if/when time permits.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 8

WCrihfield
Mentor
Mentor
Accepted solution

Hi @pavol_krasnansky.  You may want to consult someone at Autodesk about the best way to translate your drawing document(s) from one language to another.  That is a really large and complex task to tackle by iLogic code if you are just planning on using a find & replace type strategy on all the many possible types of objects that may be present within an Inventor DrawingDocument that can contain text.  There are several objects within a drawing that we still do not even access to by API or iLogic code yet.

 

If you want to keep trying to tackle this by code, the code will likely need to be greatly expanded due how many different types of objects it may have to process through, and will likely need a lot of potential error avoidance built into it, to keep it from erroring out part way through the task.  Many types of things that can contain a TextBox, may have several different aspects to them also, such is the case with Borders, TitleBlocks, SketchedSymbols, and some others, where you may need to check within the TextBox.Text property, within the TextBox.FormattedText property, and when it represents a prompted entry, you also need to check its currently shown value with one method, then set an edited value for it using a different method.  Then the FormattedText usually contains XML tags, which is another programming language, and replacing something in that may break its functionality, but may be necessary.

 

I attached a text file below with some code in it you can play around with.  Within that I decided to split several of those larger, more complex objects out into their own separate Sub routines, in an attempt to keep the main routine's code a bit cleaner, and easier to read through, without getting overwhelmed.  As you can see, I am only covering 3 possible objects, and the overall code is already pretty long.  I mentioned many other possible object types you may want to look into, but do not have time to create working, error free solutions for all of them right now.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 8

pavol_krasnansky
Enthusiast
Enthusiast

Thank you very much for your code and your time 🙂 I try it include to my application for exporting documentations from the Inventor. I will try to add also another objects from the drawing. I am lucky I don't use all objects 🙂 My second plan is that I try to use editing PDF for replace text.

0 Likes
Message 5 of 8

pavol_krasnansky
Enthusiast
Enthusiast

Hi @WCrihfield. Can you please help me with replacing the text in weld note in the drawing? I have translated all objects in my rule, which I need now except the weld note...
Than you

0 Likes
Message 6 of 8

WCrihfield
Mentor
Mentor

Hi @pavol_krasnansky.  Unfortunately, I believe that is one of the object types that we do not yet have access to through Inventor's API or iLogic yet.  We do have access to the similar SurfaceTextureSymbol, but not for weld symbols yet.  There are several other types of objects related to welds that we do have access to, like the WeldBead, WeldBeads, WeldmentComponentDefinition, Weld, WeldsComponentDefinition, & Welds objects.  Some of these have a ReadOnly property called WeldInfo, which returns a String that is formatted using XML tags, and may contain some useful data, but that is not the actual weld note that you put on your drawing sheet.  Maybe access to these through API/iLogic will become available in near future releases of Inventor, but not yet in 2023 version so far.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 7 of 8

WCrihfield
Mentor
Mentor

It seems like I may have heard of others using something like a custom SketchedSymbolDefinition object(s) that they designed for use as things like Balloons and weld symbols.  That way they have more control over them by code in their drawing automation solutions.  These can either have a leader or not, and can contain static text, linked text, or prompted entry type text, depending on how you design them, and/or how you choose to place them in your drawings.  This may be an alternative to the drawing weld symbols that you could look into, and maybe replace existing regular weld symbols with your custom ones.  Just a thought.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 8 of 8

pavol_krasnansky
Enthusiast
Enthusiast

Thank you very much @WCrihfield! When I need a note in the weld mark, I will use a GeneralNote or a LeaderNote.

0 Likes