For the last few days I've been having problems appending or attaching a translation record to an object node. The error message I get is "Attempted illegal attach" or "Attempted illegal append"
- Both the object and the translation records are created without errors
- The object is attached to the top node, "g2" in my case, without errors. I tried attaching the object to the top node before and after attaching the translation record, but that made no difference
It seems to be just the appending or attaching that fails but I have no clue as to why, and I have done this many times before without a problem.
Is there any way of getting more information on this error message? Has anyone had a similar problem? What might be the cause of an "illegal attach"?
Appreciate any thoughts/ideas/suggestions
Just some background info - I wrote several scripts that perform different tasks in an Openflight file. I'm now merging them into a single script with multiple options, and am in the process of re-factoring quite a lot of code. Everything else is working fine and this is the only real problem I've encountered that I can't seem to get around
This particular message is displayed when the transformation node "belongs" to a different database than the object to which you are attaching it. This is not allowed because of the way memory garbage collection is handled in the API. Nodes cannot be moved from one database to another.
When you create a node using the API with mgNewRec, there is a "current" database set. This is the database that the new node belongs to. You must make sure the current database is the database (when you create the new node) into which you are going to attach/append/insert the new node.
Most likely you are working with multiple open databases simultaneously and creating the transformation node when a different database is current than the one in that contains the object. Consider the function mgSetCurrentDb to set the current database correctly before you create nodes.
On a side note, I will log an issue to get more detail included in this message for the next user it affects.
Aah right. I am opening another database, doing a mgDuplicateToDb to copy an object into a new database. Then later in the script I duplicate and move this object all over the place in the new database; so what you said sounds spot on and my problem is probably to do with the current database being used.
Thanks yet again Steve - will hack away and report back with my findings
you were right - adding the line
prior to mgDuplicateToDb() fixed the problem right away.
This has bugged me all weekend, I'm so happy right now
SteveThompson.thanks += 1