What I want to do now is make a command that modifies parameters which includes replacing the source item thru a new blockreference that I import.
What happens if you
- select your AssocArray,
- use the GetParameters() method to obtain an AssocArrayParameters object,
- downcast that to AssocArrayPathParameters,
- try to modify it according to your wishes,
- and finally call the Commit() method on AssocArrayPathParameters?
Example in F#, I hope you'll get the gist:
let selectAnArray (ed : Editor) =
let peo = new PromptEntityOptions("\nSelect an Associative Array: ")
let per = ed.GetEntity peo
if per.Status = PromptStatus.OK then
if AssocArray.IsAssociativeArray per.ObjectId then
Some per.ObjectId
else
ed.WriteMessage("\nNot an Associative Array, please try again...")
None
else None
[<CommandMethod "ChangeItemCount">]
let changeItemCount() =
let db = acadApp.DocumentManager.MdiActiveDocument.Database
let ed = acadApp.DocumentManager.MdiActiveDocument.Editor
match selectAnArray ed with
| None -> ()
| Some oid ->
let array = AssocArray.GetAssociativeArray oid
match array.GetParameters() with
| :? AssocArrayPathParameters as p ->
let pir =
new PromptIntegerOptions(
"New value for ItemCount",
AllowNegative = false,
AllowZero = false,
DefaultValue = p.ItemCount,
UseDefaultValue = true )
|> ed.GetInteger
if pir.Status = PromptStatus.OK then
p.ItemSpacing <- p.ItemSpacing * float p.ItemCount / float pir.Value
p.ItemCount <- pir.Value
p.Commit()
AssocManager.EvaluateTopLevelNetwork(db, null, 0)
|> ignore
| _ -> ()
Edit: Commit() and example added.