AnsweredAssumed Answered

Pull component height from PCB database & Library

Question asked by cjtx on May 11, 2017
Latest reply on Jun 19, 2017 by cjtx

Howdy all y'all!

 

     I'm very much a beginner with automation , .net, VB, efm, vbs.   I figured this may be an easier task to start with. I'd like to get the heights for each part and tie to variable or write out to a text file then do something else with it later.  I found the PCB Automation Model 7.9.4.  I'm thinking I need to "call" one of these objects.properties to get the data?   Maybe Component>FindProperty? 

 

 

So have been throwing some things together below but definitely know I'm missing a lot.  Trying to use a message box now to test but will/can swap this out with some code to write to text instead.   Looking for any help with direction or maybe start over :-)

 

 

 

 

Option Explicit

'Add any typ libraries to be used.

Scripting.AddTypeLibrary("MGCPCB.ExpeditionPCBApplication")

Scripting.AddTypeLibrary("MGCPCB.PlannerPCBApplication")

 

' Get the Application object

Dim pcbAppObj

Dim filesys

Dim compheightfile

'Set pcbAppObj = Application 

'On error resume next

'Set pcbAppObj = GetObject(,"MGCPCB.ExpeditionPCBApplication")

'If (Err) then

  'If won't open in Expedition try Planner

Set pcbAppObj = GetObject(,"MGCPCB.Application")

Set filesys = CreateObject("Scripting.FileSystemObject")

Set compheightfile = filesys.CreateTextFile("./compmaxheights.txt", True)

' Err.clear

'end if

' Get the active document

Dim pcbDocObj

Set pcbDocObj = pcbAppObj.ActiveDocument

 

' License the document

ValidateServer(pcbDocObj)

 

 

'Get the parts collection

Dim partsColl: Set partsColl = pcbDocObj.Parts

 

'

Dim Coll

Dim i, j

Dim cmpObj

Dim Height

Dim refDes

 

 

 

 

 

partsColl.Item(i).Height(epcbUnitMils)

 

 

Dim compmaxheightinfo

compmaxheightinfo = "Height (mils): " & vbCRLF & refDes & vbTab & Height & vbCRLF & vbCRLF & "Height (mils): "_

& vbCRLF & refDes & vbTab & Height & vbCRLF'vbCRLF & vbCRLF_

'& "Height (mils): " & vbCRLF & refDes & vbTab & Height & vbCRLF

 

'msgbox compheightinfo  '"Height: " & vbCRLF & refDes & ", " & Height & " mils" & vbCRLF & vbCRLF_

         '& "Height: " &vbCRLF & refDes& ", "  & " mils"

compheightfile.WriteLine compheightinfo

Outcomes