when the putComponet returns Nothing, the placement has failed.
I would propose to set a LockServer ( with set DRC=FALSE) before the PutComponent (at the end do not forget UnlockServer)
The it should place the component and return the component object as desired.
Another way for debugging is, to look for all the placed cells in the design.
Last Idea is to put a user property on the cell by automation.
Then, when selecting the cell later interactively, you can see it in the properties window.
You could use this to show, which number in your placement sequence it was.
Thanks for the reply, Andreas.
I understand that when putComponent returns nothing, it means the placement has failed. From what I've tested in my code, though, the putComponent method returns nothing even though the drawing cells were placed successfully. I have tried setting a variable to become the component object that is returned and testing the placed property, and that seems to always come back as true, regardless if the drawing cell was successfully placed or not.
Here's the snippet of code:
Ycoord = 0
Do While Ycoord > Ymin
Xcoord = 0
Do While Xcoord > Xmin
Set rtnVal = pcbDoc.PutComponent(cell,False,Xcoord,Ycoord,0)
' If rtnVal Is Nothing Then
' oFile.WriteLine("Placement failed at " & Xcoord & "," & Ycoord)
' oFile.WriteLine("..." & rtnVal & "...")
' End If
Xcoord = Xcoord - pitch
Ycoord = Ycoord - pitch
I also tried gathering the collection of drawing cells that were placed, and reporting their x-y coordinates... but to no avail! The comp.Count property is correct (I checked it, deleted a few drawing cells, then re-checked), and I can get the comp.Level property to report but neither the comp.CenterX/Y or comp.PositionX/Y properties report anything! Here's the code that I used to test this:
Set compColl = pcbDoc.Components(4,-1,1)
' msgBox cellColl.Count
x = 1
For Each comp In compColl
' Xcoord = comp.PositionX(curUnits)
' Ycoord = comp.PositionY(curUnits)
Xcoord = comp.CenterX(curUnits)
Ycoord = comp.CenterY(curUnits)
dFile.WriteLine(x & ". " & Xcoord & "," & Ycoord & " Level = " & comp.Level)
x = x + 1
I've attached the debug.txt that this code was reporting to.
As next step I would try o one step back.
Just test your code snippets by
- select a placed drwaing cell interactive
- use pcbDoc.Components(epcbSelcetSelected,epcbCompAll,epcbCelltypeDrawing) to create a one item component collection
- in CompCollection.item(1) search for all your properties like positionand so on.
I assume there is an wron