Change text based on code

Change text based on code

caio.guimaraes7LVGH
Participant Participant
346 Views
2 Replies
Message 1 of 3

Change text based on code

caio.guimaraes7LVGH
Participant
Participant

Greetings!

 

I'll just outright explain what I need and then explain what I'm trying.

 

I need to indicate in a drawing sheet its size. Thus, if it's A4, then I want to appear somewhere on the screen: "A4 210x297".

 

What I'm trying to do is: making a piece of code that reads what's the name of the sheet format and changes a parameter. Then I wanted to change a text field based on that parameter. I failed on my first step, so I came here before even trying the second one.

 

So, if you may help me, I wanted to ask two things:

 

  • Is there a easier way to do this? Mind you, I wanted it to be completely automated: we already have 5 different sheet formats with different sizes.
  • Regardless if there is, I'd like to do this with iLogic and VBA because I wanted to learn. Is there a way to do this?
    • Proceeding with this code, how do I go about changing a text field based on a parameter I created? I have a parameter called test. Can I simply go on about a particular field and set it for its contet to be the same value as parameter 'test'? I have NO clue as to how to go about this.

My code was a rule I created with this written:

 

Sub main()

Sheet_size = ThisDrawing.ActiveSheet.Name

Parameter(test) = text_return(Sheet_size)
End Sub

Function Sheet_size(sheet As String) As String
	If sheet Is "A4"
		text = "A4 xx.xx"
	End If
End Function

Trying this returns me with an error: Parameter: Could not find a parameter named: ""

 

I'm currently in a A4 sized sheet.

 

0 Likes
Accepted solutions (1)
347 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

You cas try this code (iLogic)

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim SheetSize = oDoc.ActiveSheet.Size

If SheetSize = kA0DrawingSheetSize Then
	text = "AAA"
Else If SheetSize = kA1DrawingSheetSize Then
	text = "BBB"
Else If SheetSize = kA2DrawingSheetSize Then
	text = "CCC"
Else If SheetSize = kA3DrawingSheetSize Then
	text = "DDD"
Else If SheetSize = kA4DrawingSheetSize Then
	text = "EEE"
End If

It will change "text" parameter depending on size of sheet.

0 Likes
Message 3 of 3

caio.guimaraes7LVGH
Participant
Participant

It worked to change the parameter, thanks!

 

Still atempting to input the parameter in the text label, following this instruction but not quite getting it to work.

0 Likes