Anonymous
448 Views, 5 Replies
07-27-2018
01:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
07-27-2018
01:06 AM
osheet
i have some coding and keep getting the error "oSheet" is not declared coding below
SyntaxEditor Code Snippet
'START Quit=MessageBox.Show("Do you wish to run this rule?","title",MessageBoxButtons.YesNo) If Quit=7 Then Exit Sub End If TableCheck:'------------------------------------------------------'---------------start finding the table----------------'------------------------------------------------------ For i = 1 To oSheet.CustomTables.Count TableTitle = oSheet.CustomTables.Item(i).Title If TableTitle = "Operating Conditions" Then 'Remember the table number for editing section TableNr = i 'If table found jump to edit section Goto EditTable End If Next '------------------------------------------------------'---------------end finding the table----------------'------------------------------------------------------ 'CreateTable:'------------------------------------------------------'---------------start creating the table---------------'------------------------------------------------------' Set the column titles oTitles = New String(){"Item", "Description"}' ' ' ' Create the custom table oCustomTable = oSheet.CustomTables.Add("Operating Conditions", ThisApplication.TransientGeometry.CreatePoint2d(15, 15), _ 2, 11, oTitles,oContents, oColumnWidths) '------------------------------------------------------'---------------finish creating the table---------------'------------------------------------------------------'edit the table by restarting the check routine Goto TableCheck EditTable:'------------------------------------------------------'---------------start editing the table---------------'------------------------------------------------------'Get the name Of the first model in the drawing modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName) 'MessageBox.Show(modelName, "ilogic")' ' ' ' '------------------------------------------------------'---------------finish editing the table---------------'------------------------------------------------------
07-27-2018
06:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
07-27-2018
06:20 AM
Hi bpWallis17,
You haven't declared oSheet. Is your entire rule shown or have you cut some out of it?
The code doesn't know what oSheet is. More than likely, you need something like this above what you've shown.
Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet
oSheet = oDrawDoc.Sheets.Item(1)
This is assuming you want to work on the first sheet of the document.
Thanks,
Randy Mabery
Applications Expert
IMAGINiT Technologies
08-02-2018
09:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
08-02-2018
09:02 AM
'START
Quit=MessageBox.Show("Do you wish to run this rule?","title",MessageBoxButtons.YesNo)
If Quit=7 Then
Exit Sub
End If
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDrawDoc.Sheets.Item(1)
TableCheck:'------------------------------------------------------'---------------start finding the table----------------'------------------------------------------------------
For i = 1 To oSheet.CustomTables.Count
TableTitle = oSheet.CustomTables.Item(i).Title
If TableTitle = "Operating Conditions" Then
'Remember the table number for editing section
TableNr = i
'If table found jump to edit section
GoTo EditTable
End If
Next
'------------------------------------------------------'---------------end finding the table----------------'------------------------------------------------------
'CreateTable:'------------------------------------------------------'---------------start creating the table---------------'------------------------------------------------------' Set the column titles
oTitles = New String(){"Item", "Description"}'
'
'
' Create the custom table
oCustomTable = oSheet.CustomTables.Add("Operating Conditions", ThisApplication.TransientGeometry.CreatePoint2d(15, 15), _
2, 11, oTitles,oContents, oColumnWidths)
'------------------------------------------------------'---------------finish creating the table---------------'------------------------------------------------------'edit the table by restarting the check routine
GoTo TableCheck
EditTable:'------------------------------------------------------'---------------start editing the table---------------'------------------------------------------------------'Get the name Of the first model in the drawing
modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
'MessageBox.Show(modelName, "ilogic")'
'
'
'
'------------------------------------------------------'---------------finish editing the table---------------'------------------------------------------------------Hi, it's working fine here. The only place I see a possible issue is if your drawing doesn't have a model in it. It could fail as currently written if there is no drawing view of a model to get in that last line.
Thanks,
Randy Mabery
Applications Expert
IMAGINiT Technologies