Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to assign SW part dimension to variables in VBA?

Status
Not open for further replies.

WilliUSF

Mechanical
Feb 6, 2002
8
Can anyone tell me the syntax for getting dimension values from a SW part and assigning these values to variables in VBA?
When I run a certain macro on a certain part I want the macro to find specific dimensions in the part and assign the dimension values to variables within the macro. I've been able to get my macro to change dimension values in the part but I don't know the proper syntax for grabbing an existing value of a dimenion. I've seached the FAQ and saw information there that leads me to believe that this is possible but, no details were given as to how.

I am very much a newbie to VBA and Visual Basic. Thank you for your help. Hopefully someday I'll be able to give back to this forum!!
 
Replies continue below

Recommended for you

Use the same as you do when you set the dimension. The SystemValue method is a Read/Write function. Here is a little snipit that will double the existing value.
Code:
Dim rVal As Double
rVal = Part.Parameter("dim@sketch").SystemValue 
rVal = 2 * rVal
Part.Parameter("dim@sketch").SystemValue = rVal
Hope that helps...
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
well the process goes like this...

You need to select the dimension (usually by name) and then you query the dimension value and set the variable to the value....

First what I would do is create an object like this in the declarations:

Dim DimVal As Object

Then in the sub main I would write a line like this:

Set DimVal = Part.Parameter("D1@Sketch1")


Next I would find out what the value was of that paramter was as set it to a variable. , like this :

a = DimVal.SystemValue

so essentially we create an object
define the object as the part paramter name
then read the system value of the parameter and set that value to "A"

hope that helps a little Regards,
Jon
jgbena@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor