osheet

osheet

Anonymous
Not applicable
530 Views
5 Replies
Message 1 of 6

osheet

Anonymous
Not applicable

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---------------'------------------------------------------------------

0 Likes
531 Views
5 Replies
Replies (5)
Message 2 of 6

R.Mabery
Advocate
Advocate

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
0 Likes
Message 3 of 6

Anonymous
Not applicable

i now get this message after adding your bit in "Object reference not set to an instance of an object."

0 Likes
Message 4 of 6

R.Mabery
Advocate
Advocate

Is this your entire code?

 


Thanks,
Randy Mabery
Applications Expert
IMAGINiT Technologies
0 Likes
Message 5 of 6

Anonymous
Not applicable

yes it is i assuming theres something missing ?

 

0 Likes
Message 6 of 6

R.Mabery
Advocate
Advocate
'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
0 Likes