iLogic Insert Text Parameter into a Text Field

iLogic Insert Text Parameter into a Text Field

fce
Enthusiast Enthusiast
3,497 Views
7 Replies
Message 1 of 8

iLogic Insert Text Parameter into a Text Field

fce
Enthusiast
Enthusiast

Hello there,

I´m trying to create an iLogic rule to replace the author of old drawings (which is written manually) with the current author of the drawing, but I would like to keep the author as a text parameter <Author> and not as simple text.
I managed to changed but only as simple text. I´m sure that I´m just missing the correct function. 
Bellow the current code. I would really appreciate some quick help.

'---------------------
' Replace "FCE" , "MPO", "RMO", "BAR", "DGO", "HJD" with Author
'Is the active document a drawing document?
If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then Dim objDoc As Document objDoc = ThisApplication.ActiveDocument Dim objDrawDoc As DrawingDocument objDrawDoc = objDoc Dim colTitleBlkDefs As TitleBlockDefinitions colTitleBlkDefs = objDrawDoc.TitleBlockDefinitions Dim objTitleBlkDef As TitleBlockDefinition For Each objTitleBlkDef In colTitleBlkDefs ' If we are here, we have the title block of interest. ' Get the title block sketch and set it active Dim objDrwSketch As DrawingSketch Call objTitleBlkDef.Edit(objDrwSketch) Dim colTextBoxes As TextBoxes colTextBoxes = objDrwSketch.TextBoxes Dim objTextBox As TextBox For Each objTextBox In colTextBoxes Select Case objTextBox.Text Case "FCE", "MPO", "RMO", "BAR", "DGO", "HJD" If objTextBox.Text <> UserFullName ' I´M STRUGGLING WITH THIS NEXT LINE objTextBox.FormattedText = "<StyleOverride FontSize='0,25'>" & iProperties.Value("Summary", "Author") & "</StyleOverride>" ' Exit For Else done=1 Exit For End If End Select If done = 1 Exit For End If Next objTextBox Call objTitleBlkDef.ExitEdit(True) Next objTitleBlkDef End If

 

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

johnsonshiue
Community Manager
Community Manager

Hi! I am not an iLogic expert. But, I think you might approach the issue in a wrong way. Where did the following values originally come from? Where they from the Author iProperty? If yes, you should change the iProperty value and everything will update accordingly.

 

"FCE", "MPO", "RMO", "BAR", "DGO", "HJD"

 

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 3 of 8

fce
Enthusiast
Enthusiast

The values "FCE", "MPO", "RMO", "BAR", "DGO", "HJD" were manually written. 
I would like to eliminate this old method.

0 Likes
Message 4 of 8

fce
Enthusiast
Enthusiast

Do you have any idea how to achieve it?

0 Likes
Message 5 of 8

JhoelForshav
Mentor
Mentor

Hi @fce 

How about this? 🙂

'---------------------
' Replace "FCE" , "MPO", "RMO", "BAR", "DGO", "HJD" with Author
'Is the active document a drawing document?
If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then

	Dim objDoc As Document
	objDoc = ThisApplication.ActiveDocument
		  
	Dim objDrawDoc As DrawingDocument
	objDrawDoc = objDoc
	Dim colTitleBlkDefs As TitleBlockDefinitions
	colTitleBlkDefs = objDrawDoc.TitleBlockDefinitions
	Dim objTitleBlkDef As TitleBlockDefinition

		For Each objTitleBlkDef In colTitleBlkDefs
		' If we are here, we have the title block of interest.
		' Get the title block sketch and set it active
		Dim objDrwSketch As DrawingSketch
		Call objTitleBlkDef.Edit(objDrwSketch)
		Dim colTextBoxes As TextBoxes
		colTextBoxes = objDrwSketch.TextBoxes
		Dim objTextBox As TextBox
			For Each objTextBox In colTextBoxes
				
				Select Case objTextBox.Text
				Case "FCE", "MPO", "RMO", "BAR", "DGO", "HJD"
				If objTextBox.Text <> UserFullName								
                                ' I´M STRUGGLING WITH THIS NEXT LINE
				objTextBox.FormattedText = "<Property Document='drawing' PropertySet='Inventor Summary Information' Property='Author' FormatID='' PropertyID=''>AUTHOR</Property>"
	
'					Exit For
				Else
					done=1
					Exit For
				End If
				End Select
			
				If done = 1
					Exit For
				End If
			Next objTextBox
		Call objTitleBlkDef.ExitEdit(True)
		Next objTitleBlkDef
		
End If
0 Likes
Message 6 of 8

fce
Enthusiast
Enthusiast

Hello JhoelForshav,
thanks a lot, it works.
How would you add the style override like in the previous version of the rule?

objTextBox.FormattedText = "<StyleOverride FontSize='0,25'>" & UserFullName & "</StyleOverride>"

 Greetings,
Francisco

 

0 Likes
Message 7 of 8

JhoelForshav
Mentor
Mentor
Accepted solution

Glad it works @fce 

Try this to include the style override 🙂

objTextBox.FormattedText = "<StyleOverride FontSize='0,25'> <Property Document='drawing' PropertySet='Inventor Summary Information' Property='Author' FormatID='' PropertyID=''>AUTHOR</Property> </StyleOverride>"
Message 8 of 8

fce
Enthusiast
Enthusiast

Nice! That´s awesome, Thanks.

0 Likes