Jump to content
Developer Wiki and Function Reference Links ×

Script that manipulates drop shadows on symbols that are embedded in other symbols, does not work on embedded symbols recently added.


Recommended Posts

Hey all;

I'm having issues with a python script that attempts to configure and turn on drop shadows (ie vs.SetDropShadowData and vs.EnableDropShadow) on symbols embedded within symbols. The code works on the embedded symbols that were origionally added, when the 'outer' symbol was first created. But if I edit the outer symbol, and add new symbiol instances within it, the script fails to work on the new symbols. Details and a test file are below. 

 

Attached Document has two Symbols, and a test script in it.
"innerSymbol" is simply an oval, turned into a symbol.
"BaseSymbol" in folder "BaseSymbols" is a square, with above 'InnerSymbol" oval added to it, then turned into a symbol.
"Add Drop Shadows To Inner Symbols" is the test script.

 

The actual script code is included separately below as well. 


Load the file, and run the script. The "InnerSymbol" inside "BaseSymbol" gets a green drop shadow as expected. This works fine.
Now edit "BaseSymbol", and drag another "InnerSymbol" into it.
Run the test script again. The new "InnerSymbol" does NOT get the green drop shadow as expected. This is the behavior that I'm trying to fix.
Next manually edit the new "InnerSymbol" drop shadow parameters, and change any one of the parameters. In my case, I changed the units from "page" to "document". But editing any parameter seems to work.
Run the test script yet again. This time, the new "InnerSymbol" picks up the drop shadow change just fine.

- Why does the new "InnerSymbol" initially NOT pick up the drop shadow changes applied to it by the code?
- Why does manually editing the drop shadow parameters, then allow the script to work as expected?
- Is there any change I can make to the script to allow it to work, without needing to first manually edit drop shadow parameters?

This issue also seems to happen on MacOS.

Many thanks,

Andy Goar

 

MyDropShadowInnerSymbolTestDocument2.vwx

Link to comment

Many thanks for the idea.

 

I had tried that, though I stripped it out of the script in the file I shared. I just added it back in, just ot be sure. The script still does not work as expected. 

Here is the updated script code. Is this what you had in mind (see comments)?
 

import vs


def ModifyInnerSymDropShadows(BaseSym):
    BaseSymName = vs.GetSDName(BaseSym)
    #print("Adding shadows to inner symbols for base: " + BaseSymName);
    innerSym = vs.FInGroup(BaseSym)
    while (innerSym):
        vs.SetDropShadowData(innerSym, 1, 15.0, 0.01 ,290.0 ,100, (0,35466,14649))
        vs.EnableDropShadow(innerSym, True)
        vs.ResetObject(innerSym)                # Added this as per JBenghiat's suggestion
        vs.ResetBBox(innerSym)
        #print("  Inner object found, and shadows added")
        innerSym = vs.NextObj(innerSym)

# Main code. Walks through all symbols in "BaseSymbols" folder, and calls routine 
# to add drop shadows. 
BaseSymList, BaseSymCount = vs.BuildResourceList(16, 0, 'BaseSymbols')

for BaseSymIndex in range(1, BaseSymCount + 1):    
    currSym = vs.GetResourceFromList(BaseSymList, BaseSymIndex)
    ModifyInnerSymDropShadows(currSym)
    vs.ResetObject(currSym)                # Added this as per JBenghiat's suggestion
    
vs.ReDrawAll()

Again, what really gets me, is that one embeded symbol, the one that was added when the outer symbol was first created, gets the drop shadow just fine. The 'print' statements showed me that the other symbol, the one that was added when I edited the outer symbol later, does have the SetDropShadowData/EnableDropShadow operations applied to it. But the shadow just does not show up. But if I manually add a drop shadow, then rerun the script, everything works. 

 

Again, thank you so much for posting your idea. Any other thoughts you may have are GREATLY appreciated. This issue is really stopping up some plans we have. 

Andy

Link to comment

There seems to be something wrong with your test symbol — possibly some bad values got in there during testing.  If you build the symbol again and run the script, it seems to work as expected.

 

I am seeing a bug with nested symbols with drop shadows, where view changes cause it to render incorrectly.

Link to comment
  • 3 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...