Pulsonix User Forum

Technical advice from Pulsonix engineers and the wider community.

 All Forums
 Help with using Pulsonix
 Scripting
 Unsupported attribute property or method error

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON

   Upload a file

Check here to subscribe to this topic.
   

T O P I C    R E V I E W
SeK Posted - 28 Oct 2018 : 19:38:21
Hi all,

I created a little script for the automated processing of component attributes. The goal is to loop over all components in a schematic design and check, if there is an attribute with the name "Value". If the value of attribute "Value" has a metric suffix, it should be expanded. For instance, Value=10.2k is expanded to 10200 or 5u is expanded to 0.000005.

Processing of the input data works fine, but I have the problem that the script often aborts with the error

quote:
Object doesn't support this property or method: 'Attr.Value'
.

To reproduce this behaviour I cut down the script to a minimum


' vbs
Set Design = ActiveDocument()
if not Design is Nothing then
  if Design.IsScm() then
  	Set Comps = Design.Components()
    'Test
    for each Comp in Comps
      Set CompPart = Comp.Part      
      Set Attr = CompPart.FindAttribute("Value")
      Message(Comp.Name)
      if Attr.Value = "" then
        Message(Comp.Name & " Value is empty")
      end if
  	next
  else
  	Message("Not a Schematic design")
  end if
end if


and run it within a test design with a few components that all have the attribute "Value". It aborts with

quote:
Object doesn't support this property or method: 'Attr.Value'
Src. Runtime error in Microsoft VBScript
Line11: Error:0 Scode:800a01b6


Replacing 'Attr.Value' with 'Attr.Name' in line 11 shows the same behaviour.

It is striking that the minimum version of my script mostly aborts at the second loop run of 'for each Comp in Comps'. But the original script aborts at a more or less undefined time.

Any ideas?



SeK
1   L A T E S T    R E P L I E S    (Newest First)
Jochen Posted - 30 Oct 2018 : 08:41:24
Hi SeK,

there are 2 problems with your script:

- You try to get the 'Value' attribute from the underlying Part of a Component. If you added or changed this attribute for a Component in your schematics, this is not reflected by the script.
- If an attribute does not exist in a Pulsonix item, you always get a runtime error. You have to check if your Attr object exists after you try to get it from the database by inserting a check like 'if not Attr is nothing then'.

So the script would look like


' vbs
Set Design = ActiveDocument()
if not Design is Nothing then
  if Design.IsScm() then
  	Set Comps = Design.Components()
    'Test
    for each Comp in Comps
      'Set CompPart = Comp.Part      
      Set Attr = Comp.FindAttribute("Value")
      Message(Comp.Name)
      if Not Attr Is Nothing then
	      if Attr.Value = "" then
	        Message(Comp.Name & " Value is empty")
	      end if
	    end if
  	next
  else
  	Message("Not a Schematic design")
  end if
end if


Hope this helps.

Jochen