×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*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.

# Macro: Parameter, Remove constant.

 Forum Search FAQs Links MVPs

## Macro: Parameter, Remove constant.

(OP)
Hi All,

I've recently started creating a few macros to help my team with some of the more tedious aspects of our work within CATIA. Mainly to aid with the Airbus HnF tool.

One of the Parameters generated by the tool is set to "Constant" by default, as a means to "lock" the parameter. Does anyone know the correct code term I would use to remove the "Constant" Lock, change the value and then reapply the "Constant" Lock?

I've been trawling the net/forums for any hint as to the correct syntax for setting constant to false on a parameter but to no avail!!!!

I thought it would be simple as:

Set parm = objShape.GetParameter("Synchronized")

parm.Constant = false

parm.Value = "True"

Any help would be much appreciated.

Cheers

Chris

### RE: Macro: Parameter, Remove constant.

Hi,

Can you upload a sample and make a screenshot to see which exactly parameter you need to modify?

### RE: Macro: Parameter, Remove constant.

What do you mean by "Constant lock"?

### RE: Macro: Parameter, Remove constant.

one possible solution... not the best.. but works (sometimes)..
hopefully someone can share a better method.

#### CODE -->

Sub Lock_Modify_Unlock()

Dim oActiveDoc As Document
Set oActiveDoc = CATIA.ActiveDocument
oActiveDoc.Activate
Dim oParameters As Parameters
Set oParameters = oActiveDoc.Part.Parameters

Set ostrPar = oParameters.Item("Synchronized")

Dim selection1 As Selection
Set selection1 = oActiveDoc.Selection
selection1.Clear

Dim objShell As Object
Set objShell = CreateObject("WScript.Shell")

CATIA.StartCommand ("UnLock")
Application.Wait 1000
objShell.SendKeys "{ENTER}"

ostrPar.Value = "modified"

selection1.Clear

CATIA.StartCommand ("Lock")
Application.Wait 1000
objShell.SendKeys "{ENTER}"

End Sub 

______

Alex ,

### RE: Macro: Parameter, Remove constant.

(OP)
Thanks for your replies guys!

Ferdo, I've attached screen grab of the node/parameters I’m trying to modify. The parameter in question is "Sychronized". The node itself is created by a macro called HnF which we use for creating Holes/Fastener geometry and info. Each node is populated with these parameters. When a new fastener is generated the parameters are locked by default (though not visibly) There is an unlock function in the toolbar that allows you to then edit all the parameters EXCEPT the "Synchronized" parameter. We have the code segment to run the unlock function for the rest of the parameters but it does not unlock "Synchronized".

#### CODE --> VBA

Sub SetSyncToTrue( objDoc )
Set objSel = objDoc.Selection

For i=1 To objSel.Count2
Set objItem = objSel.Item2(i)
Set objShape = objItem.Value
If CheckHnF(objShape) Then
Set parm = objShape.GetParameter("Synchronized")

'''Suppress read-only (This turns off the Parameters Invisible Lock)
AIFHnFGsdLockUnlockParametersHdr
parm.SetEnumerateValues(Array("DummyVal"))
parm.SuppressEnumerateValues()
End If

''' This is where I need to specifically unlock "Snychronized"
parm.Lock = false

End If

Next
End Sub 

Garzar, I simply mean the parameter is locked; the value has been set to "constant". I realise this is the normal way in which a parameter is locked but the macro that creates these parameters does not lock the others in this manner, the parameter can be locked and not have the "Constant" box selected in the parameter properties.

Alex, Thanks for the code but unfortunately I’m editing a .catvbs file, as far as I’m aware the CATIA.StartCommand doesn’t work in this kind of code? Although I’m willing to be corrected on that!

### RE: Macro: Parameter, Remove constant.

Hi,

I know HnF Airbus tool, I'm a little bit surprised to see that parameter locked, normally should be not locked (at least that was the case in my company and in Airbus). If I will have time, I will try to see how it can be done.

The HnF tool is not a simple macro as far as I know.

### RE: Macro: Parameter, Remove constant.

(OP)
Thanks Fernando,

For us Synchronized is always shown as locked, its value remains "True" until you edit any of the other parameters, at which point it changes to "false" automatically. Our Standard states this should always read "True", but when we create "drill_only" nodes we have no choice but to edit the other parameters to make sure they are populated correctly. Hence the requirement for us to change the "Sychronized" parameter back to "True". Doing this manually for a model that conatains 100's of fasteners is painfully tedious and time consuming. Automating this would be a real bonus for us!

### RE: Macro: Parameter, Remove constant.

(OP)
A Quick update,

So I'm still wrestling with this macro in between jobs. I read yesterday that parameter unlock isnt possible via .catvbs, you have to use .CATScript.

I tried Alex's code but that didnt seem to work, with some digging online I found this code:

#### CODE --> CATScript

Sub CATMain()

Set objPart = CATIA.ActiveDocument.Part

'Select the parameter
Set objSel = CATIA.ActiveDocument.Selection
objSel.Clear

'To unlock
CATIA.StartCommand "Unlock"

'To lock
'CATIA.StartCommand "Lock"

'Clear the selection
objSel.Clear

End Sub 

This works in that it initiates the unlock process, One step closer!!!! But now the issue is when the parameter unlocks a pop up window asks to confirm the unlock. Can someone help me finish this code so that it will "SendKeys" to enter after the unlock, change the parameter value to "true" then re-lock (will require a SendKeys command again)?

Ideally i'd also want to be able to run this script within an assembly applying the script to all items selected.

If anyone can help me out with this it'd much appreciated, my knowledge of CATIA.StartCommand is even less than my knowledge of CATvbs!!!

Cheers

Chris

### RE: Macro: Parameter, Remove constant.

Hi

Chris, I would do something else, select all parameters by name in one shot, run the command Unlock and let designer push OK button, all will be unlocked in a single step. You can change then parameters value in a loop (another macro) and a third macro to lock again.

Of course all this can be done also in catvba (not catvbs) with sendkeys as Alex already shown but in my experience this is not the best idea. You can do sendkeys command in catscript or catvbs calling a vbs file from outside CATIA but again, I wouldn't recommend (search forum, there is an example).

In catvba you need to do something like bellow to use sendkeys (and let CATIA work, don't do something else, otherwise you can change the window and sendkeys will be send to another window).

CATIA.StartCommand ("Unlock")

PauseTime = 3 ''play with the figure here...
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
Finish = Timer
TotalTime = Finish - Start

CATIA.RefreshDisplay = True
SendKeys "{Enter}", True

#### 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.

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

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

#### Resources

White Paper: Industrial Control Basics: Contactors
A contactor is an electrical device used for switching an electrical circuit on or off. Considered to be a special type of relay, contactors are used in applications with higher current carrying capacity, while relays are used for lower current applications. Download Now
Research Report: State of IoT Adoption in Product Development 2019
This research report, based on a survey of 234 product development professionals, examines the current state of Internet of Things (IoT) adoption by product design teams, its perceived importance, and what features and capabilities teams consider important when making decision about adding IoT functionality to their products. Download Now
Research Report: Augmented Reality for Maintenance, Repair and Overhaul (MRO)
The term Industry 4.0 denotes a cluster of technologies thatâ€™s poised to fundamentally reshape manufacturing and bring about a new industrial revolution. These include 3D printing (AM), the Industrial Internet of Things (IIoT), artificial intelligence (AI) and mixed reality technologies, more commonly known as virtual reality (VR) and augmented reality (AR). Download Now

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!