[JW Lua] Deleting a given Test/Shape Expression Def

Charles O. Lawrence charlesolawrence at bellsouth.net
Sun Sep 7 23:34:41 CEST 2014


Thanks for the help.  I'll keep working on it.  Anxiously awaiting the new
beta.

Note that my goal is not to delete any expressions as placed in the
document, but rather to delete any unused expression defs from a selected
category that show in the selection grid.  Except for the missing
DeepDeleteData() and the remapping, I think I have developed an algorithm
that does the job.

Charles

-----Original Message-----
From: JWLua [mailto:jwlua-bounces at jwmusic.nu] On Behalf Of Jari Williamsson
Sent: Sunday, September 07, 2014 4:59 PM
To: The JW Lua script plug-in.
Subject: Re: [JW Lua] Deleting a given Test/Shape Expression Def

On 2014-09-07 21:52, Charles O. Lawrence wrote:

> There is no DeepDeleteData() method for either FCTextExpressionDef or 
> FCShapeExpressionDef classes, only DeleteData().  There is a 
> DeepSaveAs() for both.  Is an argument required for these methods?

That's not good... I need to add DeepDeleteData() here. A new beta should
arrive within the next 24 hours, where that will be available.

DeleteData() and DeepDeleteData() don't have any argument. SaveAs() and
DeepSaveAs() need the location where it should be saved, but you shouldn't
need those methods for deleting defs.


> Excuse my ignorance, but how do you remap the expressions?  I tried at 
> the end to do a SaveAll() and another LoadAll(), but that doesn't seem to
do it.

First, never use SaveAll() on a collection where you have deleted data. 
Some of the objects in the collection will now point to empty data storage
that will most probably be resaved. Using LoadAll() again would work fine to
refresh things, however.

Please note that "expressions" are not the same as "expression defs" in this
context. The expression is the placed object in the document, pointed to by
FCExpression objects.

The pseudo code for remapping could be something like this:
1. Calculate the new new expression def ItemNo number. For example if you
delete text expression def 54, all text expression defs at 55 and above will
be one less.
2. Parse through each measure in the document 3. Load all expressions for
each measure (using
FCMeasure:LoadAllForItem() with the measure number as argument) 4. Parse
through all expressions loaded at step #3 with the each() iterator 5.
Determine if the expression is shape or text and change the "ID" to reflect
the new shape/text expression def number. Resave the expression.


Best regards,

Jari Williamsson



_______________________________________________
JWLua mailing list
JWLua at jwmusic.nu
http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu





More information about the JWLua mailing list