Author Topic: How do I set my undo operation?  (Read 1193 times)

0 Members and 1 Guest are viewing this topic.

highflyingbird

  • Bull Frog
  • Posts: 385
  • Later equals never.
How do I set my undo operation?
« on: October 19, 2011, 09:30:20 pm »
I created a Jig,   invoked  a LISP function in  AcEdJig::update() . 
C++ code:
Code: [Select]
Adesk::Boolean Highflybird_Jig::update ()
{
        .........

        int ret(0);
        resbuf *rb_in = NULL;
        resbuf *rb_out = NULL;

        rb_in = acutBuildList(RTSTR,_T("test"), RT3DPOINT,m_CurPt,RTNONE);
        if (rb_in == NULL)
        {
                return RTERROR;
        }
        ret = acedInvoke(rb_in,&rb_out);
        if (ret == RTERROR || rb_out == NULL)
        {
                acutRelRb(rb_in);
                acutRelRb(rb_out);
                return RTERROR;
        }
        ........
}
LISP code
Code: [Select]
(vl-acad-defun 'test)
(defun test (dynpt)
  (foreach obj lst
    (vla-move obj (vlax-3d-point p0) (vlax-3d-point dynpt))
    (ENTUPD (vlax-vla-object->ename obj))
  )
  (setq p0 dynpt)
)
it worked, but I wanted  to undo  my arx operation, I failed. 
So  How do I set my undo operation  in arx?
« Last Edit: October 19, 2011, 09:38:25 pm by HighflyingBird »
I am a bilingualist,Chinese and Chinglish.

frtfff

  • Newt
  • Posts: 188
Re: How do I set my undo operation?
« Reply #1 on: October 20, 2011, 07:58:52 pm »
 :lmao:

Alexander Rivilis

  • Newt
  • Posts: 178
  • Programmer from Kiev (Ukraine)
Re: How do I set my undo operation?
« Reply #2 on: October 21, 2011, 08:29:14 am »
Code: [Select]
#include <acadi.h>
void UndoStart(void)
{
  IAcadApplication *pAppAcad = (IAcadApplication *)acedGetAcadWinApp()->GetIDispatch(TRUE);
  if (pAppAcad) {
    IAcadDocument *pAcadDoc = NULL;
    if (pAppAcad->get_ActiveDocument(&pAcadDoc) == S_OK) {
      pAcadDoc->StartUndoMark();
      pAcadDoc->Release();
    }
    pAppAcad->Release();
  }
}
void UndoEnd(void)
{
  IAcadApplication *pAppAcad = (IAcadApplication *)acedGetAcadWinApp()->GetIDispatch(TRUE);
  if (pAppAcad) {
    IAcadDocument *pAcadDoc = NULL;
    if (pAppAcad->get_ActiveDocument(&pAcadDoc) == S_OK) {
      pAcadDoc->EndUndoMark();
      pAcadDoc->Release();
    }
    pAppAcad->Release();
  }
}

highflyingbird

  • Bull Frog
  • Posts: 385
  • Later equals never.
Re: How do I set my undo operation?
« Reply #3 on: October 22, 2011, 02:24:52 am »
Alexander Rivilis,thank your very much.
I tested your way,but it  doesn't work yet.I don't know  why.
Acturally, I admire your  "dyndraw" ,learned  a lot from it, so I want to do myself.
I used two ways -one is JIG, another is acedDragGen, both can work.
With JIG , I can't go back ,look at the capture, the entities can't go back their origin positions;  but  with acedDragGen,I  can  undo my operations.
So ,here I posted my source code, and my LISP samples.wish you can help me.
p.s. Thanks for anybody's suggestions.
I have compiled all  versions (2004-2012 ) in ..\release.
If you want to test it,please appload  arx file according to your CAD version at first,then you can run Lisp samples.
There are six commands : test,ttt,txx,tcc,tmm,trr,tins. some of them aren't translated English,sorry.I will translate them later.
« Last Edit: October 22, 2011, 02:32:28 am by HighflyingBird »
I am a bilingualist,Chinese and Chinglish.

nullptr

  • Bricscad
  • Needs a day job
  • Posts: 6554
  • AKA Daniel
Re: How do I set my undo operation?
« Reply #4 on: October 23, 2011, 06:06:19 pm »
you might have a look and see what AcDbDatabase::undoRecording is returning

highflyingbird

  • Bull Frog
  • Posts: 385
  • Later equals never.
Re: How do I set my undo operation?
« Reply #5 on: October 23, 2011, 08:29:57 pm »
you might have a look and see what AcDbDatabase::undoRecording is returning
I did, and  it returns  "true". Thank you a lot.
I was wondering Alexander Rivilis's, I can undo opereations correctly by his program.
So ,if just set "StartUndoMark","EndUndoMark",where should I put them ?
I am a bilingualist,Chinese and Chinglish.

nullptr

  • Bricscad
  • Needs a day job
  • Posts: 6554
  • AKA Daniel
Re: How do I set my undo operation?
« Reply #6 on: October 24, 2011, 02:56:58 am »
another thing you can try, is to use a transaction, I think this sets the undo marks for you

highflyingbird

  • Bull Frog
  • Posts: 385
  • Later equals never.
Re: How do I set my undo operation?
« Reply #7 on: October 24, 2011, 05:46:22 am »
another thing you can try, is to use a transaction, I think this sets the undo marks for you

I tried this before,but  I got the same result.

Today, I put the acedInvoke into  "sampler()",then I can undo,but the entities can't update.
       
I am a bilingualist,Chinese and Chinglish.

highflyingbird

  • Bull Frog
  • Posts: 385
  • Later equals never.
Re: How do I set my undo operation?
« Reply #8 on: October 30, 2011, 08:47:43 pm »
I tried transcation again.
but this time ,I divided them. I invoked LISP function in sampler(),I updated Entities in Update().
Now ,it looks fine. but, It has better performance  in CAD2012  than 2006 or 2008,etc.
Sometimes , It will bring some problem ,like "0XC0000005" error,I don't know whether is it the transcation problem? occasionally  I can't go back.
So, if somebody can see my code and give me suggestion, I really appreciate.

Thanks  Daniel and Alexander Rivilis's again.
« Last Edit: October 30, 2011, 10:09:04 pm by HighflyingBird »
I am a bilingualist,Chinese and Chinglish.