Welcome to the COE Discussion Forum! 

 

To participate in the discussion forum, you must be logged in to the website.  If you forget your login information, please contact COE Headquarters at coe@coe.org or (800) 263-2255.

If you are new to the COE Discussion Forum and would like to participate, please register.


Register Today
COE 2009 Annual PLM Conference & TechniFair

COE DISCUSSION FORUM
Subject: Control Parameters with VBA User Form

You are not authorized to post a reply.   
Author Messages
LOSTINTHEFLOOD

01 Apr 2008 01:03 AM

Hi all. I need your help.

If I have a user form where the users will write wanted values for defined parameters.

How do I get the value from the form to the corresponding parameter?

In the picture: If I write 20 in Parameter 1, the parameter Param 1 should receive the value 20, Param 2 should receive its value and so on when OK is pressed. If I want to change a parameter again I should use the form and write for instance 30 in Parameter 1 and that will result in Param 1 = 30.

 

What does such code look like? 

 

My form code looks like this:

 

Private Sub cmdCancel_Click()

    Unload Me

    Exit Sub

End Sub

 

Private Sub cmdOk_Click()

    Dim lngParameter1 As Long

    Dim lngParameter2 As Long

    Dim lngParameter3 As Long

    If frmParameters.txtParameter1.Value <> "" Then lngParameter1 = frmParameters.txtParameter1.Value

    If frmParameters.txtParameter2.Value <> "" Then lngParameter2 = frmParameters.txtParameter2.Value

    If frmParameters.txtParameter3.Value <> "" Then lngParameter3 = frmParameters.txtParameter3.Value

   

    Unload Me

   

    Call SetParameters(lngParameter1, lngParameter2, lngParameter3)

   

End Sub

 

 

Thanks in advance

Thomas






CARBAHOLIC

03 Apr 2008 03:06 PM
First, I would switch the boxes on your from from text boxes to numeric updowns. That way you'll get a number out every time instead of a string.

Then, you would do something like this:

Dim MyPrtDoc as PartDocument
MyPrtDoc = Catia.ActiveDocument

Dim MyPrt as Part
MyPrt = MyPrtDoc.Part

Dim MyParms as Parameters
MyParms = MyPrt.Parameters

Dim Parm1 as Parameter
Parm1 = MyParms.item("Param 1")

Parm1.value = NumericUpDown1.value

That's off the top of my head, so there might be a typ-o or mistake, but that's the basic Idea.
LOSTINTHEFLOOD

08 Apr 2008 09:02 AM

Thank you.

I will try that

 

 

LOSTINTHEFLOOD

21 Nov 2008 03:17 AM

Just wanted to let you know that I have solved the issue.

What I did was:

Option Explicit
Dim MyPartDoc As PartDocument
Dim MyPart As Part
Dim MyParms As Parameters
Dim objWidth As Object

Private Sub cmdButton_Click()

Set MyPartDoc = CATIA.ActiveDocument
Set MyPart = MyPartDoc.Part
Set MyParms = MyPart.Parameters

Set objWidth = MyParms.Item("Width" )  'Width is the name of the parameter

objWidth.ValuateFromString dblWidthValue & "mm"   'Send value from text box to the width parameter.

 

/T

You are not authorized to post a reply.
Forums > COE Forums > CATIA V5 Programming > Control Parameters with VBA User Form



ActiveForums 3.6

    

401 North Michigan Avenue, Chicago, IL 60611-4267 | (312) 321-5153 | (800) COE-CALL (U.S.)