AnsweredAssumed Answered

putobstruct works in excel but not in a script

Question asked by juergen.dickler on Nov 12, 2017
Latest reply on Nov 14, 2017 by kendall_hiles

Hello all

I'm facing a problem and did not find it after hours of searching.


In Excel it works fine but not in a script or mentor script form. Getting the message type conflictconflict.PNG.


I will get a selected plane obstruct and copy it to x other layers

Here the core code:


Dim pcbApp
Dim pcbDoc

Dim putlayer
Dim npoints
Dim AoP
Dim obst
dim obtype


  Set pcbapp = GetObject(, "MGCPCB.ExpeditionPCBApplication")
  Set pcbDoc = pcbapp.ActiveDocument

    If ValidateServer(pcbDoc) = 0 Then
        MsgBox "Document Validation failed."
    End If


set obst = pcbDoc.Obstructs(epcbObstructAll, epcbSelectSelected)
AoP = obst.item(1).Geometry.PointsArray
obtype = obst.item(1).ObstructType
npoints = UBound(AoP,2) +1
putlayer = 2 ' only one for testing

set obst = pcbDoc.PutObstruct(putlayer,0, npoints, AoP,obtype )


Why it works in Excel and not in a script? What is wrong?