Author Topic: Programmatically set project parameters [SOLVED]  (Read 1799 times)

0 Members and 1 Guest are viewing this topic.

Offline RibsterTopic starter

  • Frequent Contributor
  • **
  • Posts: 250
  • Country: be
  • Electronics prototyper. Design. Prototype. Consult
    • Ash Labs
Programmatically set project parameters [SOLVED]
« on: May 07, 2020, 09:32:40 am »
Hello all

I have made a script that automatically alters all the parameters in each sheet of a project.
Programmed in VBS, works great.

Now i want to add this metadata onto my PCB.
I cannot access the schematic parameters from my PCB, but i can access project parameters.
I can set them and couple them from my PCB, which is great.

Now: how do i access these values from VBS ?
Can't seem to find a good starting point for this.

Kind Regards
« Last Edit: May 07, 2020, 06:51:41 pm by Ribster »
www.ashlabs.be
Design and manufacturing of embedded hard- and software
 

Offline RibsterTopic starter

  • Frequent Contributor
  • **
  • Posts: 250
  • Country: be
  • Electronics prototyper. Design. Prototype. Consult
    • Ash Labs
Re: Programmatically set project parameters
« Reply #1 on: May 07, 2020, 06:51:30 pm »
I found some piece of code in Pascal (Or is it Delphi ?)

https://electronics.stackexchange.com/questions/373311/how-can-i-change-the-project-parameters-in-altium-designer-with-a-delphi-script

So i converted this to VBS and it works!
For future reference:

Code: [Select]
Sub setProjectParameter(PARAMNAME, PARAMVALUE)
  ' Get pcb project interface
  Dim workspace           ' As IWorkspace
  Set workspace = GetWorkspace

  Dim pcbProject          ' As IProject
  Set pcbProject = workspace.DM_FocusedProject
  Dim paramFound
  paramFound = 0

  If pcbProject Is Nothing Then
      ShowMessage("ERROR: Current project is not a PCB project")
      Exit Sub
  End If

  If pcbProject.DM_ParameterCount > 0 Then
      Dim paramNum
      For paramNum = 0 To pcbProject.DM_ParameterCount - 1
          Dim projParameter
          Set projParameter = pcbProject.DM_Parameters(paramNum)
          If projParameter.DM_Name = PARAMNAME Then
              paramFound = 1
              Parameter = pcbProject.DM_Parameters(paramNum)
              Parameter.DM_SetValue(PARAMVALUE)
          End If
      Next
  End If

  If paramFound=0 Then
    'Create parameter
    Call pcbProject.DM_AddParameter(PARAMNAME, PARAMVALUE)
  End If

End Sub
www.ashlabs.be
Design and manufacturing of embedded hard- and software
 
The following users thanked this post: thm_w, ANTALIFE


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf