1

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.

Alex
  • 11
  • 2

1 Answers1

2

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;
William
  • 21
  • 1
  • 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? – jherbold Apr 10 '19 at 19:10