1
\$\begingroup\$

How can I change the project parameters in Altium Designer with a Delphi Script. I already found a script on how to change the Sheet Parameter, but I really need to change the Project Parameters.

\$\endgroup\$
2
\$\begingroup\$

Here's how I do it:

procedure SetProjectParameter(ParamName,ParamValue : String);
var
  Project       : IProject;
  Parameter     : IParameter;
  i             : Integer;
  notfound      : boolean;
begin
  Project := GetWorkspace.DM_FocusedProject;
  If Project = Nil Then Exit;
  notfound:=True;
  If Project.DM_ParameterCount >0 then
  begin
    for i:=0 to Project.DM_ParameterCount-1 do
    begin
      if Project.DM_Parameters(i).DM_Name = ParamName then
      begin
        Parameter:=Project.DM_Parameters(i);
        if Parameter.DM_Value  ParamValue then Parameter.DM_SetValue(ParamValue);
        notfound:=False;
      end;
    end;
  end;
  if notfound=True then // if parameter not found, create a new one
  begin
    Parameter:=Project.DM_AddParameter(ParamName,ParamValue);
  end;
end;
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I think the line "if Parameter.DM_Value ParamValue then Parameter.DM_SetValue(ParamValue);" should read "if Parameter.DM_Value <> ParamValue then Parameter.DM_SetValue(ParamValue);" Or am I mistaken? \$\endgroup\$ – jherbold Apr 10 '19 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.