I've added a loop to look at all attributes and if the Part Number attribute is found to print it.
I guess I need to figure out how to directly call the Part Number attribute rather then searching for it with a loop.
See the attached file.
Component.AddAttribute is what you need to use to add a property to a component.
Search the help for this function and you will find the entire syntax.
Take note that you have to use the NAME=VALUE syntax, such as:
scomp.addattribute("MY_PROP=MY_PROP_VALUE", 0, 0, 0)
and the coordinates you put in are relative to the component, not absolute coordinates of the sheet.
Sorry, I wasn't too clear. I need to extract the part_number property from the components on my board.
Basically to add the part number to my pick and place file.
Thanks for your reply.
Something like this:
Dim scomp as ViewDraw.Component
Dim attrs as Object
Dim attr as Viewdraw.Attribute
Dim design_name As String
scomps = Nothing
'load all components into scomps. scomps will get a reference to every component in the design
design_name = app.GetProjectData.GetiCDBDesignRootBlock(app.GetActiveDesign())
scomps = app.DesignComponents("", design_name, "-1", , False)
For Each scomp In scomps
attrs = scomp.attributes
for each attr in attrs
if attr.name = "part_number"
You could also use attr = scomp.FindAttribute("part_number"), but then you have to check to see if attr is nothing. It could be slightly faster
Thanks for your help.