[JW Lua] Deleting a given Test/Shape Expression Def
Jari Williamsson
jari.williamsson at mailbox.swipnet.se
Sun Sep 7 22:59:05 CEST 2014
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
More information about the JWLua
mailing list