I want to extract refdes, cell name & part number for each component in PCB. How to do this using VB script? Can any one help me out for this?
There is a ais.vbs script under Mentor install directory, you can modify one to fit your need.
a ready script modified from ais.vbs is here:
Dim pcbDoc, app
Dim fso, f1
Dim outputFileName, outputString
Dim pcbComps, pcbComp, i, designNumber
Public Function GetLicensedDoc(appObj)
On Error Resume next
Set GetLicensedDoc = Nothing
Set docObj = appObj.ActiveDocument
If (Err) Then
Call appObj.Gui.StatusBarText("No active document: " + _
key = docObj.Validate(0)
Set licenseServer = CreateObject("MGCPCBAutomationLicensing.Application")
licenseToken = licenseServer.GetToken(key)
Set licenseServer = Nothing
If (Err) Then
Call appObj.Gui.StatusBarText("No active document license: " + _
Set GetLicensedDoc = docObj
On Error Resume Next
Set app = GetObject(, "MGCPCB.Application")
If Err Then
Set app = GetObject(, "MGCPCB.FablinkXEApplication")
' create a file system object for data output
Set fso = CreateObject("Scripting.FileSystemObject")
' dump the component information
Call app.Gui.StatusBarText("output in process",epcbStatusField1)
Set pcbDoc = GetLicensedDoc(app)
If (Not pcbDoc Is Nothing) Then
designNumber = pcbDoc.Name
numberOfLayers = pcbDoc.LayerCount
outputFileName = pcbDoc.Path + "report.txt"
Set f1 = fso.CreateTextFile(outputFileName, True)
f1.WriteLine("ReferenceDesignator CellName PartNumber")
Set pcbComp = pcbDoc
Set pcbComps = pcbDoc.Components
For Each pcbComp In pcbComps
If (pcbComp.Placed = True) Then
outputString = pcbComp.Name +" "+pcbComp.Cell+" "+ pcbComp.partnumber
app.Gui.Display "The output file is " & outputFileName
Set fso = Nothing
Set pcbDoc = Nothing
Set app = Nothing
Thanks for your quick reply and timely help. But when I run this script it generates the report.txt file with only headers of the components. It's not extracting the refdes, cellname & partnumber from the components. As per the coding if the components placement is true it should extract the information from component. I read the coding fully. I don't know where it went wrong. I have attached the output file for your reference. Can you help me on this to extract the component informations?
This scripts works well. I don't know what happened on your side. BTW, Why not use the report writer to get this type of list?
In report writer, its not possible to take the cell name as report from PCB.
What you have pointed out is correct. But it will report only topcell & bottom cell. I need the alternative cell also to be in report. So this can be able to make it through only script.
Here is a script that exports Refdes,Side, Used cell, Comp type and part number of placed components to excel.
Might not work for embedded components (we don't use that so didn't look into checking for that)
Thank you very much........ It works and I am very happy to work with this.