Contact US

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!

*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

Macro: Parameter, Remove constant.

Macro: Parameter, Remove constant.

Macro: Parameter, Remove constant.

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.



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
Dim oParameters As Parameters
Set oParameters = oActiveDoc.Part.Parameters

Set ostrPar = oParameters.Item("Synchronized")

Dim selection1 As Selection
Set selection1 = oActiveDoc.Selection

selection1.Add ostrPar

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

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

ostrPar.Value = "modified"

selection1.Add ostrPar

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

End Sub 


Alex ,

RE: Macro: Parameter, Remove constant.

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


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)                                                                         
           If parm.ReadOnly Then
           End If                                                                                 
          ''' This is where I need to specifically unlock "Snychronized"                                                    				
              parm.Lock = false
               End If  
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.

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.

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.Add objPart.Parameters.Item("Synchronized")

'To unlock
 CATIA.StartCommand "Unlock"
'To lock
 'CATIA.StartCommand "Lock"
'Clear the selection

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!!!



RE: Macro: Parameter, Remove constant.


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

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! Already a Member? Login


Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. 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:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close