Pulsonix User Forum

Technical advice from Pulsonix engineers and the wider community.

Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help with using Pulsonix
 Scripting
 [solved] Get all attributes of a part
Author Previous Topic Topic Next Topic  

toko_23

Germany
5 Posts

Posted - 03 Jan 2014 :  08:01:09  Show Profile  Reply with Quote
Hi !

I use the scripting language of pulsonix to generate specific partlists. Therefore the script runs well. Now I want generate datasheets from each part of my partlist. Each part might have different attributes. For example a capacitor has a ESR-Value and a resistor doesn’t. So I want to get a list of all attributes of a component in my partlist.

Here is a code example (VB Script) :


set Design = OpenDocument(„xxxxxxx.sch“)
set PartsInList = Design.Components()
set Writer = NewReportWriter()
strFullName = Design.BasePathName() + ".html"
Writer.Open strFullName, "", false
Writer.ISHtml = true

for each Comp in PartsInList

- Code to catch all Attributes and their values
- Loop to plot the attribute name and value

next

Writer.EndTable()
Writer.Close()
Writer.View()

I don't know how get all attributes from a component. The GetAttribute() function only gives one, which i know that it exists.

The Report-Maker is able to do that, but I have to use the script….

Thank you !

Edited by - toko_23 on 03 Jan 2014 13:37:59

psxforum

United Kingdom
66 Posts

Posted - 03 Jan 2014 :  09:15:33  Show Profile  Reply with Quote
You can access the Attributes collection for most design items, simply by using the 'Attributes' function. If you open the Scripting Help file and find Component in the index, you will see in the shaded bar at the top that Component is derived from DesignItem. Click on DesignItem, and this takes you to the page that lists all the properties and methods for the base class. This includes Attributes, so you could write an inner loop in your code that goes something like:

for each Comp in PartsInList
set CompAttr = Comp.Attributes
for each Attr in CompAttr
Writer.Write (Attr.Name & "=" & Attr.Value)
next
next

Of course, if you want to produce a table of attributes with the attribute names across the top and the values filled in where they exist for each component, you will have to do a bit more work. You can access the list of attribute names from the design itself, perhaps doing something like this:

set AttrNames = Design.AttributeNames
for each AttrName in AttrNames
if not AttrName.Predefined then
Writer.Write(AttrName.Name)
end if
next

Hopefully that will be enough to get you moving towards what you are trying to do!

David.
Go to Top of Page

toko_23

Germany
5 Posts

Posted - 03 Jan 2014 :  11:13:39  Show Profile  Reply with Quote
Hi David,

thank you for the information.

I tried the following code, but the Attributes remain empty :
( of course they have attributes generated by myself :) )

set Design = OpenDocument("xxxxxx.sch")
set PartsInList = Design.Components()

set Writer = NewReportWriter()
strFullName = Design.BasePathName() + ".htm"
Writer.Open strFullName, "", false
Writer.ISHtml = true

for each Comp in PartsInList

set CompAttr = Comp.Attributes
Writer.Write("[" & Comp.PartName & " has Attributes : ")

for each Attr in CompAttr
Writer.Write (Attr.Name & "=" & Attr.Value)
next

Writer.Write("]")
Writer.Write("</br>")
next

Writer.EndTable()
Writer.Close()
Writer.View()

The result is :

[ST.2123.2410 has Attributes : ]
[ST.2123.2709 has Attributes : ]


Torsten
Go to Top of Page

toko_23

Germany
5 Posts

Posted - 03 Jan 2014 :  11:39:56  Show Profile  Reply with Quote
I want to make clear that I would like to access the atrributes which I entered in the PartLibrary ! Not in added in my Design !
Go to Top of Page

psxforum

United Kingdom
66 Posts

Posted - 03 Jan 2014 :  12:05:32  Show Profile  Reply with Quote
If you need to access the attributes from the Part, I suggest you try this modification:

for each Comp in PartsInList
set CompPart = Comp.Part
set PartAttr = CompPart.Attributes
Writer.Write("[" & Comp.PartName & " has Attributes : ")

for each Attr in PartAttr
Writer.Write (Attr.Name & "=" & Attr.Value)
next

Writer.Write("]")
Writer.Write("<br />")
next

Disclaimer: I haven't actually put this into a script and tried it myself, but the principle should be right.

David.

Go to Top of Page

toko_23

Germany
5 Posts

Posted - 03 Jan 2014 :  12:15:42  Show Profile  Reply with Quote
Hi David,

WORKS !

I didn't make the step "set CompPart = Comp.Part", because I thought the component is the part.

Thanks a lot !!!
Go to Top of Page
  Previous Topic Topic Next Topic  
Jump To: