AnsweredAssumed Answered

Add/delete attributes via script - Problem with Query(VDM_COMP, VD_SELECTED)

Question asked by on Jul 2, 2010
Latest reply on Nov 5, 2010 by frank.henne



i like to add/delete the property Assembled to selected components. For this purpose i use the following script:


'Get DXapp-object
Dim DXapp
Set DXapp = GetObject (,"ViewDraw.Application")
'Change property
Dim objComp, objAttribute
Dim x,y
ForEach objCompIn DXapp.Query(VDM_COMP, VD_SELECTED)
    If objComp.FindAttribute("Assembled") IsNothingThen
        If objComp.FindAttribute("Part Label") IsNothingThen
            'Get x/y of part label
            x=objComp.FindAttribute("Part Label").GetLocation().X
            y=objComp.FindAttribute("Part Label").GetLocation().Y
            'Create offset
        'Add attribute
        objComp.AddBatchAttributes("3 0 Assembled=NB")
        objComp.FindAttribute("Assembled").SetLocation x,y
'With multi-selection via Selection Box script generates here a runtime error
        'Delete attribute

If I select only 1 (LMB-Click) or add more components with Cntrl+(LMB-Click) then the code works and attachs/deletes the property to/from the component.

It also works if I use the selection filter (only pins deactivated) + Selection box.

But when I use the Selection Box (selection  filter: pins activated) and select 1 or more components

the script generates a runtime error and the property will be attached to the pin of the component and not to the component itself.

Therefore I get with every script execution another property "Assembled" added.

I have made screenshots for both situations.


Thanks for your help in advance