I wrote a rule which works really well. When opening a new idw template an iLogic form appears asking how many sheets and what size. You select and the sheets populate with individual titleblocks for each sheet (don't ask why!!)....that all works great! However, I'm trying to fix the code so it's possible to change the name of the sheets. "Sheets" is a user parameter btw
*************************************
For i=1 To Sheets
If i>ThisDrawing.Document.Sheets.count Then
ThisDrawing.Document.Sheets.add
End If
ThisDrawing.Sheet("Sheet:" & CStr(i)).TitleBlock = "COMPANY NAME " & CStr(Sheet_Size) & " TB_" & CStr(i)
ThisDrawing.Sheet("Sheet:" & CStr(i)).Border = "COMPANY NAME Border_" & CStr(Sheet_Size)
ThisDrawing.Sheet("Sheet:" & CStr(i)).ChangeSize ("" & CStr(Sheet_Size), Moveborderitems := True)
Next
If Parameter("Sheet_Size") = "A0" Then ActiveSheet.ChangeSize("A0", MoveBorderItems := True)
ElseIf Parameter("Sheet_Size") = "A0_S" Then ActiveSheet.ChangeSize("A0", MoveBorderItems := True)
ElseIf Parameter("Sheet_Size") = "A1" Then ActiveSheet.ChangeSize("A1", MoveBorderItems := True)
ElseIf Parameter("Sheet_Size") = "A1_S" Then ActiveSheet.ChangeSize("A1", MoveBorderItems := True)
ElseIf Parameter("Sheet_Size") = "A2" Then ActiveSheet.ChangeSize("A2", MoveBorderItems := True)
ElseIf Parameter("Sheet_Size") = "A2_S" Then ActiveSheet.ChangeSize("A2", MoveBorderItems := True)
ElseIf Parameter("Sheet_Size") = "A3" Then ActiveSheet.ChangeSize("A3", MoveBorderItems := True)
ElseIf Parameter("Sheet_Size") = "A3_S" Then ActiveSheet.ChangeSize("A3", MoveBorderItems := True)
ElseIf Parameter("Sheet_Size") = "A4" Then ActiveSheet.ChangeSize("A4", MoveBorderItems := True)
ElseIf Parameter("Sheet_Size") = "A4_S" Then ActiveSheet.ChangeSize("A4", MoveBorderItems := True)
Parameter.UpdateAfterChange = True
End If
InventorVb.DocumentUpdate()
ThisApplication.ActiveView.Fit
*******************************
If I change "Sheet" to Left(oSheet.Name,(Len(oSheet.Name) - 1)) in line 6,7 and 8 I would expect the rule to work however it does not. Can anyone help?
Thanks,
Lewis
Hi Lewis,
Where are you changing the name of the sheets?
Where does oSheet come from?
Maybe you could add some debugging: some message boxes with the info you are using or trying to assign.
When you say it does not work:
- is there an error?
- are the sheets created?
Cheers,
Hi Adam,
Thanks for your input.
I'd change the sheet name in the model browser in the idw.
Dim oSheet As Sheet
If I change the name of Sheet:1 for example then run the rule, the error is that "Sheet:1" does not exist....fairly obvious.
I've kinda given up on it, I'm no coding expert and cant seem to fix the loop.
Thanks,
Lewis
Hi Lewis,
So, if the code says "Sheet:1" does not exist, I'd suggest you dum their name by code to make sure what their name exactly are. e.g.
For i=1 To ThisDrawing.Document.Sheets.count
MsgBox (ThisDrawing.Document.Sheets(i).Name)
Next