Updating block ref graphics in middle of iteration (psuedo animation)

Updating block ref graphics in middle of iteration (psuedo animation)

Anonymous
Not applicable
597 Views
11 Replies
Message 1 of 12

Updating block ref graphics in middle of iteration (psuedo animation)

Anonymous
Not applicable
So what I'm trying to do is to create a psuedo animation of a block reference undergoing a transformation.

Step (0): open the ref for write
Step (1): erase the ref's old block record and make a new one
Step (2): somehow flush graphics so that the ref with its updated block record is drawn on the model space
Step (3): Sleep() for a small period of time
Step (4): repeat first three steps n times, with a transformation between each iteration

Step (2) is what eludes me. I've tried various things like draw() and assertWriteEnabled(), but to no avail.

I know that creating new block records after each iteration doesn't seem necessary, but for rather more complicated reasons, this must be done.

Thanks for any input!
0 Likes
598 Views
11 Replies
Replies (11)
Message 2 of 12

Anonymous
Not applicable
You can try these two calls: actrTransactionManager->flushGraphics(); and
acedUpdateDisplay();

If they don't work, you may have to call a regen.

Joe

wrote in message news:5779956@discussion.autodesk.com...
So what I'm trying to do is to create a psuedo animation of a block
reference undergoing a transformation.

Step (0): open the ref for write
Step (1): erase the ref's old block record and make a new one
Step (2): somehow flush graphics so that the ref with its updated block
record is drawn on the model space
Step (3): Sleep() for a small period of time
Step (4): repeat first three steps n times, with a transformation between
each iteration

Step (2) is what eludes me. I've tried various things like draw() and
assertWriteEnabled(), but to no avail.

I know that creating new block records after each iteration doesn't seem
necessary, but for rather more complicated reasons, this must be done.

Thanks for any input!
0 Likes
Message 3 of 12

Anonymous
Not applicable
I've tried various combinations of these functions...

acdbQueueForRegen( &id, 1);
actrTransactionManager->queueForGraphicsFlush();
actrTransactionManager->flushGraphics();
acedUpdateDisplay();
objPtr->draw();

...but nothing happens during the actual function execution. Only when the function stops executing do I see any changes, i.e. the full transformation I applied, not the incremental steps.

So maybe this regen thing is the way to go...can u point me to a sample or example in the ARX docs?
0 Likes
Message 4 of 12

Anonymous
Not applicable
This is how you would call the regen command from within ARX:

acedCommand( RTSTR, _T("_.regen"), RTNONE );

Joe

wrote in message news:5780143@discussion.autodesk.com...
I've tried various combinations of these functions...

acdbQueueForRegen( &id, 1);
actrTransactionManager->queueForGraphicsFlush();
actrTransactionManager->flushGraphics();
acedUpdateDisplay();
objPtr->draw();

...but nothing happens during the actual function execution. Only when the
function stops executing do I see any changes, i.e. the full transformation
I applied, not the incremental steps.

So maybe this regen thing is the way to go...can u point me to a sample or
example in the ARX docs?
0 Likes
Message 5 of 12

Anonymous
Not applicable
this regen thing doesn't work either, in fact it makes things act pretty strange...at the end of the code execution the block ref gets transformed correctly, but references the same block table record as it started with...

thanks for your suggestions so far, but i'm starting to think that there may not be a solution to this
0 Likes
Message 6 of 12

Anonymous
Not applicable
Howdy doug,

Since blocks and block refs derive from AcGiDrawable you can use the AcGs api to do this.

Start with AcGsModel::onModified on the ref...
acgsGetGsManager()->getDBModel()->onModified(pBlockRef, NULL);

you may also need... AcGsModel::invalidate(AcGsModel::kInvalidateAll).

and if it still doesn't work, try...
AcGsModel::onErased(pBlock, NULL) when you erase the block.

It's definitely do-able, you just gotta get it all in the right order and not use the AcEd editor api at alll. Use only the AcGs api and make sure you don't have the block or block ref opened for write outside of a transaction when you call into the AcGs notifications.

Regards,
Andy F.
0 Likes
Message 7 of 12

Anonymous
Not applicable
This doesn't work either, but I may be putting the calls in the wrong place. I'm basically putting them (invalidate and onModified) right after the ref sets its new block table record. It'd take too long to explain, but suffice it to say that I can't use onErased because where/when/if the block record is erased isn't exposed to me.

Also, I do everything within a transaction...maybe that's causing some problem with this AcGs api not updating the screen?

I'm sure there's some way to do it, but I've just pulled too many hairs trying to get such a trivial effect to occur 🙂
0 Likes
Message 8 of 12

Anonymous
Not applicable
Doug,

I just looked over some of my code where I change a block definition. To
get the block references to regen without regening the entire drawing, I
simply call pEnt->setVisibility( AcDb::kInvisible ) and then
pEnt->setVisiblity( AcDb::kVisible ). Make sure pEnt (which is an
AcDbEntity) is opened on the block reference.

Joe

wrote in message news:5780440@discussion.autodesk.com...
This doesn't work either, but I may be putting the calls in the wrong place.
I'm basically putting them (invalidate and onModified) right after the ref
sets its new block table record. It'd take too long to explain, but suffice
it to say that I can't use onErased because where/when/if the block record
is erased isn't exposed to me.

Also, I do everything within a transaction...maybe that's causing some
problem with this AcGs api not updating the screen?

I'm sure there's some way to do it, but I've just pulled too many hairs
trying to get such a trivial effect to occur 🙂
0 Likes
Message 9 of 12

Anonymous
Not applicable
Joe, thanks for your suggestions so far, but I couldn't get this to work either. Just to be clear, I do this resetting of invisibility *only* right? So not in combination with any other suggestion(s) in this thread?

And I do it just on the block reference right, not on anything else (e.g. the entities contained by the block record) ?
0 Likes
Message 10 of 12

Anonymous
Not applicable
all the suggestions should work so there must be something else going on we're not aware of.
0 Likes
Message 11 of 12

Anonymous
Not applicable
I do the actrTransactionManager->flushGraphics(); and acedUpdateDisplay();
after I close the block table record and then do the Invisible, Visible set.
If you just set to Visible, that won't do it. You have to set it to
Invisible and then back to Visible.

If you post your code here, we may be able to see what the problem might be.

Joe

wrote in message news:5780463@discussion.autodesk.com...
Joe, thanks for your suggestions so far, but I couldn't get this to work
either. Just to be clear, I do this resetting of invisibility *only* right?
So not in combination with any other suggestion(s) in this thread?

And I do it just on the block reference right, not on anything else (e.g.
the entities contained by the block record) ?
0 Likes
Message 12 of 12

Anonymous
Not applicable
As Andy below says, there must be something else going on, cause this doesn't work either. Thank you both for your help in trying to solve this problem though.

I would post my code but for the fact that the functions which do the actual block manipulation are pretty complex and nested. The function itself in which I'm attempting this graphics updating is simple, just a command interface, but for you to get the complete picture I'd probably have to send you the whole project, which would take you a while to decipher and is under non-disclosure besides.

Could it be that the problem is I'm not doing this graphics updating in the same function as where I actually set the blocks, but in the calling function?

Eh I guess this one will be put on the back burner for a while, at least until I rebuild my patience levels 🙂
0 Likes