Replace text - field text & leader text

Replace text - field text & leader text

Anonymous
Not applicable
4,280 Views
14 Replies
Message 1 of 15

Replace text - field text & leader text

Anonymous
Not applicable

I've created a set of "generic" equipment drawings for a client.  Whenever the client has a new piece of equipment fabricated from the drawings they assign it an equipment number (for sake of argument let's say the number is "426").  The generic drawings don't have a number, instead they have a "XXX" wherever the number should be.  Every time they fabricate off of the drawings they revise 100+ drawings to show the equipment number where the X's are.  I am looking for a piece of iLogic code or something that will help me replace the "XXX" with the equipment number so that I don't have to do it manually.

 

Now before anyone says it, I will: this is a dumb system.  I've tried to convince the client that since the "generic" set of drawings never changes then they should also have a number that never changes.  For some reason the client is not willing to try it this way, they want to continue duplicating and renumbering the drawings for every new piece of equipment.

 

Any help or ideas would be greatly appreciated.

0 Likes
Accepted solutions (1)
4,281 Views
14 Replies
Replies (14)
Message 2 of 15

Anonymous
Not applicable

I'm no expert but I'll take a stab at this. If you could have this model driven than it is doable. I'll assume for this it is one big assembly. You could open the top level assembly and go manage > bill of materials. In here you could create a custom iproperty, say called job number. This column will be inserted and here is your custom iproperty. You can thus highlight all rows and expand all. With this you could enter a job number and then paste it to every single item in the assembly. This would then have every assembly and part with a custom iproperty job number with whatever your current job number is. You could then have this custom iproperty on all the drawings to be pulled from the part that's inserted. Might take some setting up but you could in the future open the main assembly bom, highlight every "job number" custom iproperty and change them all simultaneously. Then simply run task manager to update drawings. This would accomplish the task you are asking for. Not sure if this is the best way for your scenario but I have used it in the past. Let me know if this helps you

0 Likes
Message 3 of 15

Anonymous
Not applicable

Also you could put the custom iproperty into one drawing and have that setup. You could then use the Drawing Resource Transfer Wizard to apply the new drawing template to all other drawings in one shot versus opening and changing them one by one. 

0 Likes
Message 4 of 15

Anonymous
Not applicable

Is it just the drawing number that needs to be updated each time or do you also have numbers within the drawing field as well (as your title alludes to)?

 

There might be a few ways to do this based on your answers.

iLogic could be one of tham along with Task Manager and maybe even Copy Design in Vault if you have Vault installed.

0 Likes
Message 5 of 15

Anonymous
Not applicable

Come to think of it you could make a custom border that includes the new job number as part of it. Using the tool Drawing Resource Transfer Wizard you could then transfer the border to every drawing. This is a bit of a hack way to do it but the change would stay permanent with the drawing and accomplish your goal. 

0 Likes
Message 6 of 15

Anonymous
Not applicable

It is not just the drawing number, it is also leader text and other text/labels.

 

While some of the suggestions on here are good I am trying to avoid redoing 200+ drawings (each new pieve of equipment may only have 100 or so drawings but there are over 200 in the "generic" set).  I realise that there are/were better ways of creating these drawings but unfortunatley the client was directly involved and is used to using AutoCAD (which has find & replace).  He was also pretty unwilling to bend his thinking.  Made it very difficult to make these drawings "intelligent".  At this point I am just trying to make the best of what we have.

0 Likes
Message 7 of 15

Curtis_W
Consultant
Consultant

Hi dschleede,

 

Here is an iLogic rule that looks at General Notes, Leader Notes, Title Block Field Text, and Sketched Symbols Text and will replace their values when they match the user input search string.

 

Post back if there are other text items that you need the iLogic rule to search through.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

oDoc = ThisDoc.Document
Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
Dim oGeneralNotes As GeneralNotes
Dim oGeneralNote As GeneralNote
Dim oSymbol As SketchedSymbol
Dim oSymbols As SketchedSymbols
Dim oTitleBlock As TitleBlock
Dim oTestBox as TextBox

Dim TXT2Find As String
Dim NewTXT As String

'get user input
TXT2Find = InputBox("Enter Text To Find:", "iLogic", "XXX")
'look for blank value
If TXT2Find ="" Then
Return 'exit rule
Else
'Continue rule
End If

NewTXT = InputBox("Enter Text To Replace   '"& TXT2Find _
& "'  with.", "iLogic", "****")

oSheets = oDoc.Sheets
For Each oSheet In oSheets
    Try
    oGeneralNotes = oSheet.DrawingNotes.GeneralNotes
    'look at gerenal notes
    For Each oGeneralNote In oGeneralNotes
        If oGeneralNote.FormattedText = TXT2Find Then
        oGeneralNote.FormattedText = NewTXT
        Else
        End if        
    Next    
    
    oLeaderNotes = oSheet.DrawingNotes.LeaderNotes
    'look at gerenal notes
    For Each oLeaderNote In oLeaderNotes
        If oLeaderNote.FormattedText = TXT2Find Then
        oLeaderNote.FormattedText = NewTXT
        Else
        End if        
    Next    
    
    oTitleBlock = oSheet.TitleBlock
    For Each oTextBox In oTitleBlock.Definition.Sketch.TextBoxes
                If oTitleBlock.GetResultText(oTextBox) = TXT2Find  Then
                oTitleBlock.SetPromptResultText(oTextBox, NewTXT )
        Else
        End If
        Next
    
    oSymbols = oSheet.SketchedSymbols
    'look at sketched symbols
        For Each oSymbol In oSymbols
            For Each oTextBox  In oSymbol.Definition.Sketch.TextBoxes
             If oSymbol.GetResultText(oTextBox)   = TXT2Find Then
             oSymbol.SetPromptResultText (oTextBox, NewTXT)
                Else
            End if      
            Next
            Next
            Catch
            'do nothing here,
            'this simply catches errors, for
            'exampl: when a sheet has no title block
            End Try
Next

 

 EESignature

Message 8 of 15

Curtis_W
Consultant
Consultant

   

 

****  Updated version ****

 

The Try/Catch I had in the first version didn't work as intended. Smiley Frustrated

 

This new version should work as expected, just disregard the previous version. Smiley Embarassed

 

I should point out also that this iLogic does not handle Sketched Symbols where the static text matches the searched text, as it is only looking at the prompted/field text in the symbols.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

oDoc = ThisDoc.Document
Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
Dim oGeneralNotes As GeneralNotes
Dim oGeneralNote As GeneralNote 
Dim oSymbol As SketchedSymbol
Dim oSymbols As SketchedSymbols
Dim oTitleBlock As TitleBlock 
Dim oTestBox as TextBox

Dim TXT2Find As String
Dim NewTXT As String

'get user input
TXT2Find = InputBox("Enter Text To Find:", "iLogic", "XXX")
'look for blank value
If TXT2Find ="" Then
Return 'exit rule
Else 
'Continue rule
End If

NewTXT = InputBox("Enter Text To Replace   '"& TXT2Find _ 
& "'  with.", "iLogic", "****")
'look for blank value
If NewTXT ="" Then
Return 'exit rule
Else 
'Continue rule
End If

oSheets = oDoc.Sheets
For Each oSheet In oSheets

	'handle errors
	On Error Resume Next
	
	'look at gerenal notes
	oGeneralNotes = oSheet.DrawingNotes.GeneralNotes
	For Each oGeneralNote In oGeneralNotes
		If oGeneralNote.FormattedText = TXT2Find Then
		oGeneralNote.FormattedText = NewTXT 
		Else 
		End if        
	Next    
	
	'look at leader notes	
	oLeaderNotes = oSheet.DrawingNotes.LeaderNotes
	For Each oLeaderNote In oLeaderNotes
		If oLeaderNote.FormattedText = TXT2Find Then
		oLeaderNote.FormattedText = NewTXT 
		Else 
		End if        
	Next    
	
	'look at title blocks
	oTitleBlock = oSheet.TitleBlock
	For Each oTextBox In oTitleBlock.Definition.Sketch.TextBoxes
        	If oTitleBlock.GetResultText(oTextBox) = TXT2Find  Then
        	oTitleBlock.SetPromptResultText(oTextBox, NewTXT )
		Else
		End If
    	Next
    	
	'look at sketched symbols	
	oSymbols = oSheet.SketchedSymbols
    	For Each oSymbol In oSymbols
    		For Each oTextBox  In oSymbol.Definition.Sketch.TextBoxes
 			If oSymbol.GetResultText(oTextBox) = TXT2Find Then
 			oSymbol.SetPromptResultText (oTextBox, NewTXT)
    			Else 
			End if      
    		Next
        Next
Next

 

 EESignature

Message 9 of 15

Anonymous
Not applicable

I tried your code but it doesn't seem to work.  It didn't replace any of the "XXX"'s with the other number.  Perhaps I am doing something wrong.

0 Likes
Message 10 of 15

Curtis_W
Consultant
Consultant

Hi dschleede,

 

It's possible that you have something in your drawings that are a departure from what I tested. Attached is a sample file that you can look at to see how this is working, and hopefully determine what is different than your file(s). If so you might provide some screen shots of your files to help others better understand what you're working with. But I suspect my example is too simple compared to your real world files.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

 EESignature

0 Likes
Message 11 of 15

Anonymous
Not applicable

It works in your example until you change all of the text so that the XXX's are contained inside other text.

 

ie:  55XXX-A01

 

Then it fails.

0 Likes
Message 12 of 15

Anonymous
Not applicable

Maybe this can't be handled with iLogic?  I though maybe it'd be possible to throw a wildcard in there somewhere but I've read that ilogic doesn't support wildcards.

0 Likes
Message 13 of 15

Anonymous
Not applicable

If you are still at a loss with this, I have something similar that I use with my Certification drawings.  Typically a client assigns a Tool number and I have lots of text in my drawings that reference this number (general notes, drawing number, titleblock, etc..) I use the iLogic Form function along with custom iProperties to populate all my text.  So for instance, I open the form, enter the tool number and after applying, the text is filled in with the number at the locations I specified.  It does take a bit to setup (you will have to go through all your text and title block and add in the custom iproperty).  But once finished, it is very simple and effective.  See some screen caps below...

Form for Text Entry2.jpg

Form for Text Entry.jpg

0 Likes
Message 14 of 15

Curtis_W
Consultant
Consultant
Accepted solution

 

Update to this to find string that contain the search string as requested in the past:

 

Sub main
	oDoc = ThisDoc.Document
	Dim oSheets As Sheets
	Dim oSheet As Sheet
	Dim oGeneralNotes As GeneralNotes
	Dim oGeneralNote As GeneralNote
	Dim oSymbol As SketchedSymbol
	Dim oSymbols As SketchedSymbols
	Dim oTitleBlock As TitleBlock
	Dim oTextBox as TextBox

	Dim ooTXT2Find As String
	Dim oNewTXT As String

	'get user input
	oTXT2Find = InputBox("Enter Text To Find:", "iLogic", "XXX")
	'look for blank value
	If oTXT2Find = "" Then
		Return 'exit rule
	End If

	oNewTXT = InputBox("Enter Text To Replace   '" & oTXT2Find _
	& "'  with.", "iLogic", "ZZZ")
	'look for blank value
	If oNewTXT = "" Then
		Return 'exit rule
	End If

	oSheets = oDoc.Sheets
	For Each oSheet In oSheets

		'handle errors
		On Error Resume Next

		'look at General Notes
		oGeneralNotes = oSheet.DrawingNotes.GeneralNotes
		For Each oGeneralNote In oGeneralNotes
			oText = oGeneralNote.FormattedText
			oText = ReplaceText(oText, oTXT2Find, oNewTXT)
			oGeneralNote.FormattedText = oText
		Next

		'look at leader notes	
		oLeaderNotes = oSheet.DrawingNotes.LeaderNotes
		For Each oLeaderNote In oLeaderNotes
			oText = oLeaderNote.FormattedText
			oText = ReplaceText(oText, oTXT2Find, oNewTXT)
			oLeaderNote.FormattedText = oText
		Next

		'look at title blocks
		oTitleBlock = oSheet.TitleBlock
		For Each oTextBox In oTitleBlock.Definition.Sketch.TextBoxes
			oText = oTitleBlock.GetResultText(oTextBox)
			oText = ReplaceText(oText, oTXT2Find, oNewTXT)
			oTitleBlock.SetPromptResultText(oTextBox, oText)
		Next

		'look at sketched symbols	
		oSymbols = oSheet.SketchedSymbols
		For Each oSymbol In oSymbols
			For Each oTextBox In oSymbol.Definition.Sketch.TextBoxes
				oText = oSymbol.GetResultText(oTextBox)
				oText = ReplaceText(oText, oTXT2Find, oNewTXT)
				oSymbol.SetPromptResultText(oTextBox, oText)
			Next
		Next
	Next

End Sub


Function ReplaceText(oText As String, oTXT2Find As String, oNewTXT As String)

	If oText = oTXT2Find Or oText.Contains(oTXT2Find) Then
		oText = Replace(oText, oTXT2Find, oNewTXT)
	End If
	Return oText

End Function

 EESignature

Message 15 of 15

yadurajda1
Community Visitor
Community Visitor

Really great!! i was able to replace around 10 to 20 items in seconds!!

But the text in Notes got missed(didn't get replaced). Notes were in different layer.

0 Likes