Hello,
Full code:
Dim odoc As PartDocument
Dim oProject As DesignProject
oProject = ThisApplication.DesignProjectManager.ActiveDesignProject
Dim oName As String
oName = oProject.Name
oName = "\" + oName + ".ipj"
Dim my_prop_val As String
Dim oProjectPath As String
oProjectPath = oProject.FullFileName
Dim oPath As String
oPath = oProjectPath.Replace (oName, "")
GoExcel.Open(oPath & "\_iLogic\iLogic_iProp.xlsx", "Fasteners")
'Open Excel file'
MyRow = InputBox("Specify the type:" & vbCrLf & _
"2 - Bolt" & vbCrLf & _
"3 - Screw" & vbCrLf & _
"4 - Nut" & vbCrLf & _
"5 - Washer", "Import Row", "2")
Select Case MyRow
Case "2"
my_prop_val = "Bolt"
Case "3"
my_prop_val = "Screw"
Case "4"
my_prop_val = "Nut"
Case "5"
my_prop_val = "Washer"
End Select
'Prompt User To Choose row To read In,
'Get the iProperty from selected Row For Each column
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In ThisDoc.Document.ComponentDefinition.Occurrences
odoc.oOccurrence.Definition.Document
If odoc.PropertySets(3).Item("Description").Value.ToString.ToLower.Contains(my_prop_val.ToLower) Then
iProperties.Value(oOccurrence.Name, "Summary", "Title") = GoExcel.CellValue("B" & MyRow)
iProperties.Value(oOccurrence.Name, "Custom", "Title_En") = GoExcel.CellValue("C" & MyRow)
iProperties.Value(oOccurrence.Name, "Custom", "Title_Lt") = GoExcel.CellValue("D" & MyRow)
iProperties.Value(oOccurrence.Name, "Custom", "Title_Ru") = GoExcel.CellValue("E" & MyRow)
iProperties.Value(oOccurrence.Name, "Project", "Stock Number") = GoExcel.CellValue("F" & MyRow)
iProperties.Value(oOccurrence.Name, "Custom", "Material_Shape_En") = GoExcel.CellValue("G" & MyRow)
iProperties.Value(oOccurrence.Name, "Custom", "Material_Shape_Lt") = GoExcel.CellValue("H" & MyRow)
iProperties.Value(oOccurrence.Name, "Custom", "Material_Shape_Ru") = GoExcel.CellValue("I" & MyRow)
iProperties.Value(oOccurrence.Name, "Custom", "Material_Certificate_Norm") = GoExcel.CellValue("J" & MyRow)
iProperties.Value(oOccurrence.Name, "Custom", "Material_Certificate_Type") = GoExcel.CellValue("K" & MyRow)
iProperties.Value(oOccurrence.Name, "Custom", "Material_Full") = GoExcel.CellValue("L" & MyRow)
iProperties.Value(oOccurrence.Name, "Custom", "Material_Dim_d") = GoExcel.CellValue("M" & MyRow)
iProperties.Value(oOccurrence.Name, "Custom", "Material_Dim_L") = GoExcel.CellValue("N" & MyRow)
odoc=ThisApplication.Documents.Open(odoc.oOccurrence.Definition.Document.fullfilename,True)
iProperties.Material = GoExcel.CellValue("L" & MyRow)
iProperties.PartColor = GoExcel.CellValue("P" & MyRow)
odoc.Save
odoc.Close(True)
End If
Next
Then, error message:
System.NullReferenceException: The variable of object or the variable of block With is not defined (Не задана переменная объекта или переменная блока With).
at Microsoft.VisualBasic.CompilerServices.Symbols.Container..ctor(Object Instance)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Ragards