×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to assign SW part dimension to variables in VBA?

How to assign SW part dimension to variables in VBA?

How to assign SW part dimension to variables in VBA?

(OP)
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!!

RE: How to assign SW part dimension to variables in VBA?

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.

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.

RE: How to assign SW part dimension to variables in VBA?

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources