script file for pads pcb to generate open pnp placement info

141 views
Skip to first unread message

Peter Chaisty

unread,
Feb 16, 2021, 11:00:18 AM2/16/21
to OpenPnP
Sub Main
'Openpnp_v2.BAS
' Based on Sample 17: Excel Part List Report.BAS
' PJC
'
' Generates ventroid data from Pds PCB for Open PNP

Dim TotalDrillSize As Integer

' Open  text file
Randomize
filename = DefaultFilePath & "\Positions"  & CInt(Rnd()*10000) & ".txt"
Open filename For Output As #1

     ActiveDocument.unit = ppcbUnitMetric 


' Output Headers
Print #1, """Designator"",";
Print #1, """Value"",";  
Print #1, """Footprint"","; 
Print #1, """X"",";
Print #1, """Y"",";
Print #1, """Rot"",";
Print #1, """Layer""";
Print #1, """Height""";
   
    'mils = 2
    'metric - 4
Print #1, Chr(13) & Chr(10);
' Lock server to speed up process
LockServer

' Go through each component in the design and output values
Dim nextComp As Object
For Each nextComp In ActiveDocument.GetObjects(1, "", False)
  ' If nextComp.Pins(1).DrillSize(0) = 0 Then
  
    TotalDrillSize = 0
    For iPin = 1 To nextComp.Pins.Count 
      TotalDrillSize = TotalDrillSize + nextComp.Pins(iPin).DrillSize(0)   
      Next iPin
  
  ' if drillsize is 0 it must be smd 
  If TotalDrillSize=0 Then
Print #1,""& nextComp.Name & "" + ",";
If  nextComp.Attributes("Value") Is Nothing Then
          If  nextComp.Attributes("Part number") Is Nothing Then         
              Print #1, """"& "N/A" & """" + "," ;        
            Else 
              Print #1, """"& nextComp.Attributes("Part number")  & """" + ",";
            End If
        Else
            Print #1, """"& nextComp.Attributes("Value") & """" + ",";
          End If
Print #1, """"& nextComp.Decal  & """" + ",";
            a = Format$(nextComp.PositionX(0), "00.0000")
            
        a = Format$(nextComp.PositionX(0), "00.0000" + "mm")
Print #1,""""&  a  & """" & ",";
           
        
       ' Formatting is really fussy
        a = Format$(nextComp.PositionY(0), "00.0000" + "mm")
Print #1,""""&  a  & """" & ",";
' Print #1, """";
           a = Format$(nextComp.Orientation, "000")
      '      Print #1, """" + a + """";
        '    Print#1, a
Print #1,""""&  a  & """" & ",""";
'Print #1, """";
Print #1,( ActiveDocument.LayerName(nextComp.layer))  & """,""0""" ;
'Print #1, ",""0""
        Print #1, Chr(13) & Chr(10);
  End If
 
   
Next nextComp

' Unlock the server
UnlockServer

' Close the text file
Close #1
' Display the text file
Shell "Notepad " & filename, 3

End Sub

Reply all
Reply to author
Forward
0 new messages