I am writing a macro that takes a preexisting model and adds specific features to it. To do this I need to be able to pull dimensions from the model and set them as variables.
I have gone on several threads in this forum that concern this topic, but every solution that I find gives me a "run-time error 91 - Object varialbe or with block not set"
Here is my code, error occuring at the line in red
Dim PartDia As Double
DIm PartLgth As Double
Const Metric = 0.0254
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSketchMgr As SldWorks.SketchManager
Dim swFeature As SldWorks.Feature
Dim swFeatureMgr As SldWorks.FeatureManager
Dim vSkLines As Variant
Dim boolstatus As Boolean
Dim longstatus As Long
Dim Part As Object
Dim PlaneFeature As Object
Dim newName As String
Dim myRefPlane As Object
Dim skSegment As Object
Dim myDisplayDim As Object
Dim myDimension As Object
Dim swSketch As Object
Dim Dimension As Object
Dim Doc As String
Dim skPoint As Object
'Retrieving Dimensions
'Part Diameter, pulled from original model, in metric
Set myDimension = Part.Parameter("Outside_Diameter@GrindCylindricalForm Sketch@Template - General Cylindrical Tool.SLDPRT")
PartDia = myDimension.SystemValue
PartDia = PartDia / Metric
Part.ClearSelection2 True
I am rather confused why I am getting this error considering that I am setting the object value. Also later in my code I use the same line of code and it works.(Found in blue)
'Sets wheel Radius
Set myDimension = Part.Parameter("D1@Grinding_Wheel_Sketch")
myDimension.SystemValue = WheelRad
Part.ClearSelection2 True
Why does it work in one section of my code, but not another? Is there another way to pull dimension values from a model?
Thanks,
Elizabeth
SolidworksApi macros