Macro: Parameter, Remove constant.
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
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.
Can you upload a sample and make a screenshot to see which exactly parameter you need to modify?
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Macro: Parameter, Remove constant.
RE: Macro: Parameter, Remove constant.
hopefully someone can share a better method.
CODE -->
______
Alex ,
RE: Macro: Parameter, Remove constant.
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
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.
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.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Macro: Parameter, Remove constant.
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.
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
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.
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
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...