Change a specific piece of text

Change a specific piece of text

dleesuk
Advocate Advocate
663 Views
6 Replies
Message 1 of 7

Change a specific piece of text

dleesuk
Advocate
Advocate

Hello everyone,

 

I have an iLogic rule which interogates a parts list of a fabrication drawing, specifically the REVISION column, and returns the highest letter.


Any changes to specific parts within the model cause that part's revision to increase.....A to B to C, etc.

 

From the items in the model, I create a DXF Pack containing all the plate profiles, used to make up the fabrication, for laser/water cutting.


The revision of this DXF Pack is driven by the highest revision of any plate used in the fabrication.

(If there's a plate at Rev. D, then the DXF Pack will be at Rev. D)

 

Also, I have a note on the drawing which tells the fabricator to use the highest revision of DXF Pack, ensuring they have the most up to date details.


The note reads, for example, "USE DXF PACK REVISION A"

 

I also have an iLogic rule which will search for any instance of specific entered text and changes that text to another entered string.

 

(are you still awake/following??)

 

However, this rule changes EVERY instance of the string.


What I'm asking the amazingly generous forum members is this....

 

  • Is there a way I can specifically target the DXF note text and change only the letter A (or B or C...) for the highest revision letter (found via my previous routine)??

 

My knowledge of iLogic and VB.net is getting better, but is still quite limited.

 

This is the final piece of my jigsaw i need to crack.

 

I hope I've explained it well enough

 

Can anyone help??


Regards

Darren
0 Likes
Accepted solutions (1)
664 Views
6 Replies
Replies (6)
Message 2 of 7

Frederick_Law
Mentor
Mentor

You only have one with "USE DXF PACK REVISION"?

Compare each text instance and find one with "USE DXF PACK REVISION" and only modify that one.

0 Likes
Message 3 of 7

dleesuk
Advocate
Advocate

hI @Frederick_Law,

 

Thank you for that.

 

The text search routine will hunt down and relpace "USE DXF PACK REVISION" with "USE DXF PACK REVISION B", for example. However, when I run it again, it replaces "USE DXF PACK REVISION" plus the relevant text containing the correct revision, but it doesn't get rid of the previous revision letter. 

 

I am left with this "USE DXF PACK REVISION BA" and then "USE DXF PACK REVISION CBA", etc. etc.

 

I don't know how to replace EVERYTHING in the old string with the new string.

 

This is the text search routine I found on this forum which I've doctored to my needs...

'get the text to replace
TXT2Find = "USE DXF PACK REVISION: "
'MsgBox("Text to find is " & TXT2Find, , "iLogic")
'look for blank value
If TXT2Find = "" Then Exit Sub

NewTXT = TXT2Find & oRevNo 'oRevNo is captured by another routine

For Each oSheet As Sheet In oDrawDoc.Sheets
	For Each oGeneralNote As GeneralNote In oSheet.DrawingNotes.GeneralNotes
		oGeneralNote.FormattedText = oGeneralNote.FormattedText.Replace(TXT2Find, NewTXT)
	Next
Next

 If I knew how to target that particular GENERAL NOTE then I could search within the string itself and change it to suit my needs.  

 

Can GENERAL NOTES on a drawing be given an identifying tag to be searched for???

 

It sounds as if it should be an easy ask, however....?!?!?

 

Thanks again.


Regards

Darren
0 Likes
Message 4 of 7

WCrihfield
Mentor
Mentor
Accepted solution

Does the note contain any 'dropped in' or 'live' referenced properties/parameters?  Can you show a screen captured image of that note's text while its Format Text dialog is open?  If it is just a simple note, and that text is its only contents, you can use 

If oGeneralNote.Text.StartsWith(TXT2Find) Then

oGeneralNote.Text = NewTXT

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 7

vpeuvion
Advocate
Advocate

Hello,
I don't know if I understand your problem well but if the revision is always at the end of the text, you can try this:

Dim TxtFind As String = "USE DXF PACK REVISION B"
Dim NewRev As String = "C"
Dim NewTXt As String = Left (TxtFind, Len(TxtFind)-1) & NewRev
MessageBox.Show(NewTXt)

 I hope I've helped you.

Vincent.

0 Likes
Message 6 of 7

dleesuk
Advocate
Advocate

I knew the forum would provide me with an easy solution.  I guess I knew it was easy all along.  I just wasn't that clued up on string manipulation, etc.

 

HUGE thanks to @Frederick_Law@vpeuvion and especially @WCrihfield whose solution I went with.

 

I've no doubt @vpeuvion solution will work, but first come, first served.

 

Big Licks!!


Regards

Darren
0 Likes
Message 7 of 7

Frederick_Law
Mentor
Mentor

Also, instead of changing the string with Replace, you can create a new one and replace the old one.

 

if oldstring has "REVISION" then

oldstring = "REVISION" + rev

 

Replace is slower since program need to find text first.

0 Likes