Note: You must be registered in order to post a reply. To register, click here. Registration is FREE!
T O P I C R E V I E W
toko_23
Posted - 03 Jan 2014 : 08:01:09 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 !
5 L A T E S T R E P L I E S (Newest First)
toko_23
Posted - 03 Jan 2014 : 12:15:42 Hi David,
WORKS !
I didn't make the step "set CompPart = Comp.Part", because I thought the component is the part.
Thanks a lot !!!
psxforum
Posted - 03 Jan 2014 : 12:05:32 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.
toko_23
Posted - 03 Jan 2014 : 11:39:56 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 !
toko_23
Posted - 03 Jan 2014 : 11:13:39 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 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
psxforum
Posted - 03 Jan 2014 : 09:15:33 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!