angiepeters
05-11-2005, 08:11 AM
I am trying to write code that will set parameters in Catia (a 3d modelling program) to values I have in excel. when I run it I get Run-time error 91 'Object variable or with block variable not set' and highlites the line 'set windowasm....'
I am new at this stuff and can't figure out what I am doing wrong.
Hope someone can help me!
Dim CATDocs As Documents
Dim specsAndGeomWindow1 As Window
Dim base As Document
Dim jaw As Document
Dim windowasm As ProductDocument
Dim windowprod As Product
Dim parameterslist As Parameters
Dim viewer3D1 As Viewer
Private Sub CommandButton1_Click()
Dim catia As Object
On Error Resume Next
Set catia = GetObject(, "CATIA.Application")
If Err.Number = 425 Then
Set catia = CreateObject("CATIA.Application")
Err.Clear
End If
On Error GoTo 0
osmwidth = Sheet1.Cells(12, 4).Value
osmheight = Sheet1.Cells(14, 4).Value
osmradius = Sheet1.Cells(20, 4).Value
Set windowasm = catia.Documents.Open("C:\Documents and Settings\Administrator\My Documents\skeleton\CTC3\Product1.CATProduct") :dunno
Set windowprod = windowasm.Product
Set parameterList = windowprod.Parameters
Set OverallWidth = parameterList.Item("Overall Width")
OverallWidth.Value = osmwidth
Set OverallHeight = parameterList.Item("Overall Height")
OverallHeight.Value = osmheight
Set RadLeg = parameterList.Item("Camber (leg/rad)")
RadLeg.Value = osmradius
windowprod.Update
Set SpecsAndGeomWindow = catia.ActiveWindow
Set viewer3D1 = SpecsAndGeomWindow.ActiveViewer
viewer3D1.Reframe
End Sub
I am new at this stuff and can't figure out what I am doing wrong.
Hope someone can help me!
Dim CATDocs As Documents
Dim specsAndGeomWindow1 As Window
Dim base As Document
Dim jaw As Document
Dim windowasm As ProductDocument
Dim windowprod As Product
Dim parameterslist As Parameters
Dim viewer3D1 As Viewer
Private Sub CommandButton1_Click()
Dim catia As Object
On Error Resume Next
Set catia = GetObject(, "CATIA.Application")
If Err.Number = 425 Then
Set catia = CreateObject("CATIA.Application")
Err.Clear
End If
On Error GoTo 0
osmwidth = Sheet1.Cells(12, 4).Value
osmheight = Sheet1.Cells(14, 4).Value
osmradius = Sheet1.Cells(20, 4).Value
Set windowasm = catia.Documents.Open("C:\Documents and Settings\Administrator\My Documents\skeleton\CTC3\Product1.CATProduct") :dunno
Set windowprod = windowasm.Product
Set parameterList = windowprod.Parameters
Set OverallWidth = parameterList.Item("Overall Width")
OverallWidth.Value = osmwidth
Set OverallHeight = parameterList.Item("Overall Height")
OverallHeight.Value = osmheight
Set RadLeg = parameterList.Item("Camber (leg/rad)")
RadLeg.Value = osmradius
windowprod.Update
Set SpecsAndGeomWindow = catia.ActiveWindow
Set viewer3D1 = SpecsAndGeomWindow.ActiveViewer
viewer3D1.Reframe
End Sub