AnsweredAssumed Answered

Putvia, how to...

Question asked by Alpha on Jan 27, 2011
Latest reply on Jan 28, 2011 by matthias.cosaert


Hello dear Members,
i have a 8 Layers Design. There are many vias with the via span 1-8 on the board.

Now i want to delete all these vias and replace  them with two stacked vias:
with the via span 1-3 for the first and 3-8 for second.
Very important here is that, the vias should be deleted and replaced without rerouting
the design.


i have written a script for this purpose , but it's not working properlly!
Problem is that i can delete vias from nets, but cannot place them with the methode
Putvia of the document object.

 

In order to place a via manually,i just select the net a place the via with the mouse click.
i am trying to do the same with a script but is not working.


here is the entire script:

 

 

 


Option Explicit

'Add any type libraries to be used.
Scripting.AddTypeLibrary("MGCPCB.ExpeditionPCBApplication")

'Get the Application object
Dim pcbAppObj
Set pcbAppObj = Application

'Get the active document
Dim pcbDocObj
Set pcbDocObj = pcbAppObj.ActiveDocument


'License the document
ValidateServer(pcbDocObj)
' Get the vias collection


'Get pstkObj1all the paremeters needed to put a via
Dim pstkObj1,pstkObj2

Set pstkObj1 = pcbDocObj.PutPadstack(1, 3, "026VIA")
Set pstkObj2 = pcbDocObj.PutPadstack(3, 8, "STANDARDVIA")


' Don't attach it to a component
Dim cmpObj: Set cmpObj = Nothing

' Turn off error handling so the script
' can handle DRC violations
On Error Resume Next
Err.Clear
' Add the via where the user specified.


Call pcbDocObj.PutVia(200, 200, pstkObj1, netObj, cmpObj)
Call pcbDocObj.PutVia(200, 200, pstkObj2, netObj, cmpObj)


Dim viaColl
Set viaColl = pcbDocObj.Vias

' Get the number of vias in collection
Dim countInt
countInt = viaColl.Count
MsgBox("There are " & countInt & " vias.")

Dim viaObj ,viaName,viaPositionX, viaPositionY, viaStartLayer,viaEndLayer,viaNet,pNet
Dim dX,dY

 


For Each viaObj In viaColl

viaName=viaObj.Name
viaPositionX=viaObj.PositionX
viaPositionY=viaObj.PositionY
viaStartLayer=viaObj.StartLayer
viaEndLayer=viaObj.EndLayer

If (viaStartLayer=1) And (viaEndLayer=8) Then
    viaNet=viaObj.Net
    MsgBox viaNet

    dX= CDbl(viaPositionX)
    dY=CDbl(viaPositionY)
    netObj = pcbDocObj.FindNet(viaNet)
   
    MsgBox "netObject: "&netObj &" via_PosX:"&dX &"  via_posY:"&dY

   
    viaObj.delete
    netObj.Selected=True
    
  Call pcbDocObj.PutVia(dX, dY, pstkObj1, netObj, cmpObj)
  Call pcbDocObj.PutVia(dX, dY, pstkObj2, netObj, cmpObj)
 


'' See if there was an error
' If Not Err.Number = 0 Then
'' Display the error on the status bar
' Call pcbAppObj.Gui.StatusBarText(Err.Description, pcbStatusFieldError)
'' Clear the error
' Err.Clear
' Else
'' No error. Let the user know what happened
' Call pcbAppObj.Gui.StatusBarText("Placed via.",epcbStatusField3)
' End If
      
End If

'MsgBox "ViaName:"& viaName &"  PositionX:"& viaPositionX &"   PositionY:"& viaPositionY  &"   StartLayer:"& viaStartLayer  &"   EndLayer:"&viaEndLayer
  
NExt
 

 

Function ValidateServer(docObj)
   
Dim keyInt    
Dim licenseTokenInt    
Dim licenseServerObj    
' Ask Expedition's document for the key         
keyInt = docObj.Validate(0)    
' Get license server      
Set licenseServerObj =  CreateObject("MGCPCBAutomationLicensing.Application") 
' Ask the license server for the license token   
licenseTokenInt = licenseServerObj.GetToken(keyInt)
' Release license server   
Set licenseServerObj = nothing   
' Turn off error messages (validate may fail if the   token is incorrect)  
On Error Resume Next   
Err.Clear
' Ask the document to validate the license token   
docObj.Validate(licenseTokenInt)
If Err Then  
ValidateServer = 0     
Else  
ValidateServer = 1   
End If  

End Function


Outcomes