2
\$\begingroup\$

I have done a bit of searching and haven't found a solution so I am going to ask here.

Does anyone know how to get Altium to print out a spreadsheet of all components in a schematic library including their user defined parameters?

I know I can place all the components in a library onto a schematic and create a BOM but I would think that there would be an easier and cleaner solution. My goal here is to create a spreadsheet containing all the parts of a library so I can sort them by their part number parameter.

\$\endgroup\$
3
  • \$\begingroup\$ Assuming this is a Schematic Library or an Integrated Library, not a Database or SVN Library? \$\endgroup\$
    – Daniel
    Jan 23, 2016 at 4:33
  • \$\begingroup\$ @Dainiel Yes it is for a Schematic Lib. \$\endgroup\$
    – Axis
    Jan 23, 2016 at 4:39
  • \$\begingroup\$ Pretty sure you can do this with a script in Delphi; there is a SchLib iterator \$\endgroup\$ Jan 25, 2016 at 5:23

1 Answer 1

5
+50
\$\begingroup\$

Script below.

You will need to open the script in Altium, then open your SchLib file, then Use the DXP -> Run Script menu option (the SchLib file MUST be open when you run it). Double click the function name, not the Filename or it will now run.

The script will generate a file named d:\symbolreport.txt (you can change the file name at the very bottom of the script).

Example output:

KINGBRIGHT_KP-1608SGC;Notes;*
KINGBRIGHT_KP-1608SGC;Alternative;*
KINGBRIGHT_KP-1608SGC;CheckedByOn;GoPe/2014-11-25
KINGBRIGHT_KP-1608SGC;CreatedByOn;LiTh/2014-11-05
KINGBRIGHT_KP-1608SGC;Value;Grün
KINGBRIGHT_KP-1608SGC;Comment;DIKP-1608SGC-S10
VISHAY_TLMS1000-GS08;Notes;*
VISHAY_TLMS1000-GS08;Alternative;*
VISHAY_TLMS1000-GS08;CheckedByOn;LiTh/2014-11-24
VISHAY_TLMS1000-GS08;CreatedByOn;GoPe/2014-11-20
VISHAY_TLMS1000-GS08;Value;Rot
VISHAY_TLMS1000-GS08;Comment;DITLMS1000-S12

The output is named a CSV file with the ";" as separator character if you want to import it to Excel.

Procedure PrintDataForSchLibItems();
Var
  DocType       : WideString;
  SchComponent  : ISch_Component;
  SchLib        : ISch_Lib;
  SchDoc        : ISCh_Doc;
  SchIterator   : ISch_Iterator;

  AnObject      : ISch_GraphicalObject;
  LibName       : TDynamicString;
  Iterator      : ISch_Iterator;
  PartCount     : Integer;
  ReportInfo    : TStringList;

  Document : IServerDocument;

Begin
    If SchServer = Nil Then Exit;

    // Obtain the Client interface so can get the Kind property.
    DocType := UpperCase(Client.CurrentView.OwnerDocument.Kind);
    If DocType <> 'SCHLIB' Then
    Begin
        ShowWarning('This is not a Library document!');
        Exit;
    End;

    // Obtain the schematic library interface
    SchLib := SchServer.GetCurrentSchDocument;
    If SchLib = Nil Then Exit;

    // Create a TStringList object to store data
    ReportInfo := TStringList.Create;
    ReportInfo.Clear;

    // Obtain schematic library filename
    LibName := SchLib.DocumentName;
    LibName := ExtractFileName(LibName);

    // Create an iterator to look for symbols within the library
    SchIterator := SchLib.SchLibIterator_Create;
    SchIterator.AddFilter_ObjectSet(MkSet(eSchComponent));
    PartCount := 0;

    Try
        SchComponent := SchIterator.FirstSchObject;
        While SchComponent <> Nil Do
        Begin
            // Look for child objects associated with this symbol.
            Iterator := SchComponent.SchIterator_Create;
            Iterator.AddFilter_ObjectSet(MkSet(eParameter));
            Try
                AnObject := Iterator.FirstSchObject;
                While AnObject <> Nil Do
                Begin
                   // Limit to a specific parameter only
                    If AnObject.Name = 'CreatedByOn' Then
                    Begin
                       ReportInfo.Add(SchComponent.LibReference + ';' +  AnObject.Name + ';' + AnObject.Text);
                    End;

                    // look for the next item of a symbol
                    AnObject := Iterator.NextSchObject;
                End;

                PartCount := 0;
            Finally
                SchComponent.SchIterator_Destroy(Iterator);
            End;

            SchComponent := SchIterator.NextSchObject;
        End;
    Finally
        SchLib.SchIterator_Destroy(SchIterator);
    End;

    ReportInfo.SaveToFile('D:\SymbolReport.txt');

    ReportInfo.Free;
End;
\$\endgroup\$
4
  • \$\begingroup\$ This worked great but is there a way to only print out a single user defined parameter. Currently it prints something like 909K;PARTNUM;MT-30-0003-0005 909K;DIGIKEY;541-909KLDKR-ND 909K;Comment;909K How can I get it to only print 909K;PARTNUM;MT-30-0003-0005 for each part \$\endgroup\$
    – Axis
    Jan 25, 2016 at 22:16
  • \$\begingroup\$ Above the line which contains ReportInfo.Add, add the following statement: if AnObject.Name = 'ParameterNameYouWantToPrint' Then ReportInfo.Add(....); \$\endgroup\$
    – Tom L.
    Jan 26, 2016 at 6:29
  • \$\begingroup\$ Formatting in comments is not possible as it seems? \$\endgroup\$
    – Tom L.
    Jan 26, 2016 at 6:29
  • \$\begingroup\$ I changed the script above to include your request. Make sure you change the parameter name (currently "CreatedByOn") to suit your needs. \$\endgroup\$
    – Tom L.
    Jan 26, 2016 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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