AutoCAD Electrical Forum
Welcome to Autodesk’s AutoCAD Electrical Forums. Share your knowledge, ask questions, and explore popular AutoCAD Electrical topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Action Recorder fails during Autolisp powered annotation edits

3 REPLIES 3
Reply
Message 1 of 4
process_solutions
671 Views, 3 Replies

Action Recorder fails during Autolisp powered annotation edits

The last version of AutoCAD that had a seamlessly perfectly functioning version of the Action Recorder for me was AutoCAD Electrical 2010. Each new version since fails to successfully replicate the actions/edits that were recorded when those edits involve editing Attributes or manipulating text entities using Autolisp features.

For example, I have a function I call "punchattribute"

 

(defun c:punchattribute ( / userch1 op_pnt thetxt thetxt1 thetxt2)
(initget "Override Replace")
(setq userch1 (getkword "\nIndicate wholesale Override or to Search & Replace attribute (Override/Replace)<O>:"))
(if (= userch1 nil)(setq userch1 "Override"))
(if (= userch1 "Override")
(progn
(setq op_pnt (car (cdr (entsel "\nPick attribute to edit..."))))
(setq thetxt (getstring T "\nSpecify Attribute Value:"))
(COMMAND "attedit" "y" "*" "*" "*" op_pnt "" "v" "r" thetxt "n")
);END PROGN
(progn ;ELSE = SEARCH AND REPLACE
(setq thetxt1 (getstring T "\nSpecify Attribute Value to replace:"))
(setq thetxt2 (getstring T "\nSpecify Attribute Value to replace with:"))
(setq op_pnt (car (cdr (entsel "\nPick attribute to edit..."))))
(while (/= op_pnt nil)
(COMMAND "attedit" "n" "y" "*" "*" "*" op_pnt "" thetxt1 thetxt2)
(setq op_pnt (car (cdr (entsel "\nNext attribute to apply edit to..."))))
)
)
);END IF
(princ)
)

 

The function works fine at the command line every time when invoked by the user, but fails every time when "repeated" by the Action Recorder with dialog  "Action Macro - Playback Error" w/message:

 

ACTION_RECORDER_ERROR1.png

 

I also receive Failure with the following code for text manipulations:

 

(Defun C:WASHTEXT_FORCE ( / sset1 newval newtxt count oldobj textstr StdUser)
     (initget "Std User")
     (setq StdUser (getkword "\nUse \"Standard Verbiage\" selected from list or \"User\" value?(Std/User)<User>:"))
     (if (= StdUser nil)(setq StdUser "User"))
         (prompt "\nPick text to FORCE to same text value...")
                         (setq sset1 (ssget (list (cons 0 "text"))))                                      ;GET THE 1st SELECTION SET
                         (if (/= sset1 nil)
                              (progn
                                   (initget 1)
                                   
                                   (if (= StdUser "User")
                                       (setq newval (getstring T "\nSpecify new text for ALL text entities:"))
                                       
                                       ;ELSE PROVIDE LIST OF VERBIAGE & APPLY USER SELECTION
                                       (setq newval (dos_combolist "Standardized Verbiage List" "Select desired Standardized Verbiage"
                                       '("UPDATED TO SHOW CURRENT REVISION"
                                       "UPDATED TO SHOW CURRENT REVISION - AS-BUILT"
                                       "PRELIMINARY - ISSUED FOR DESIGN REVIEW 1"
                                       "PRELIMINARY - ISSUED FOR DESIGN REVIEW 2"
                                       "PRELIMINARY - ISSUED FOR DESIGN REVIEW 3"
                                       "AS-BUILT"
                                       "PER START-UP"
                                       )
                                       )
                                       )
                                       ;ASSIGN USER SELECTION TO newval VARIABLE
                                       );END IF
                                   
                                   
                                   (setq newtxt (cons 1 newval))                                     ;CREATE AN ASSOCIATION LIST DOTTED PAIR FOR TEXT VALUE
                                   (setq count 0)
                                   
                                   (while (< count (sslength sset1))
                                        (setq oldobj (entget (ssname sset1 count)))   ;GET THE ENTITY DATA LIST OF THE [count = nth] ENTITY IN SELECTION SET
                                        (setq textstr (assoc 1 oldobj))                              ;GET THE TEXT STRING ASSOCIATION LIST
                                        (entmod (subst newtxt textstr oldobj))             ;SUBSTITUTE  NEW ASSOCIATION LIST FOR OLD ONE IN TEXT ENTITY
                                        (setq count (+ 1 count));INCREMENT COUNT
                                   );END WHILE
                              );END SELECTION SET NOT NIL PROGN
                         );END SELECTION SET NOT NIL IF
     (setq sset1 nil)
     (princ)
);END DEFUN

 

 

Is there a simple explanation fix for making these functions work fine like they did in AutoCAD 2010?

 

I have these functions Aliased in a pre-load/predefine LISP file that predefines all of my custom lisp functions which loads at start-up so PUNCHATTRIBUTE is often invoked by typing "AA" <ENTER> & WASHTEXT_FORCE is often invoked by typing "WF" <ENTER>.  These commands fail whether invoked via alias or by actual name when they are being "Played back" by the Action Recorder only (they work fine otherwise).

 

...The Action Recorder is driving me nuts lol.

 

It ALSO Fails when invoking the classic CHTEXT.LSP.... Does anyone else experience this type of issue? Is it a new feature Post-AutoCAD 2010?

 

Thanks to any who may help on this.

 

Regards,

Sean Morgan

3 REPLIES 3
Message 2 of 4

I'm still mystified by this issue however I have found a clue.

 

The problem appears to be that the Action Recorder cannot remember the selection set that is created during the AutoLISP functions from SSGET call.

 

If I record an action using WASHTEXT_FORCE (below), as I record the action, the edits occur as desired.  When I play back that action it fails at the point of selecting objects where no objects are selected & the playback bombs.

 

BUT... if I then modify the action tree by right-clicking on the <Select Objects> portion of the command sequence where failure occured & select EITHER "Use Pick FIrst Set" or "Pause for User Input" & then PLAY the action, the editing process succeeds & there is no crash.

 

Is there a setting or work-around to have the action recorder actually record the selection of objects during teh recoding process for such function as the WASHTEXT_FORCE (& others - this is just 1 of many examples of exact same problem I have)?

 

Any help or even verification that ANYBODY else can sucessfully use the WASHTEXT_FORCE function here with the 2015 Action recorder would be useful information.

 

Thanks in advance to any who can confirm/help,

-Sean

 

 

Message 3 of 4

Hi Sean,

 

The issue has been logged in our system with id 31135.

 

Also got a comment from a colleague, which I hope might be of help:

>>>>>

Possible work-around:
  For some cases, it may be beneficial to register the lisp code as a true command and then record that.
For example:
(vlax-add-cmd "MyCommand" "c:MyLispCommand")
 
The record sequence becomes....
ACTRECORD
MYCOMMAND
...
ACTSTOP

<<<<<


Cheers,



Adam Nagy
Autodesk Platform Services
Message 4 of 4

This last bit of advice (which I have finally had a chance to try) has allowed for a work-around that appears to provide for acceptable results so far as I have currently tested it. Thank you for that.

 

How I implemented this "work around"

 

I defined a function to load my commands (by assuming they are already loaded & unloading them first):

 

(Defun c:Macro_Lisp_Fix ()
;CHTEXT UTILITY
(vlax-remove-cmd "MCHT")
(vlax-add-cmd "MCHT" "C:CHT")
;WASHTEXT UTILITIES
(vlax-remove-cmd "MWT")
(vlax-add-cmd "MWT" "C:Washtext")
(vlax-remove-cmd "MWF")
(vlax-add-cmd "MWF" "C:Washtext_Force")
(vlax-remove-cmd "MWM")
(vlax-add-cmd "MWM" "C:Washtext_Match")
(vlax-remove-cmd "MWP")
(vlax-add-cmd "MWP" "C:Washtext_Prefix")
(vlax-remove-cmd "MWS")
(vlax-add-cmd "MWS" "C:Washtext_Suffix")
(vlax-remove-cmd "MWC")
(vlax-add-cmd "MWC" "C:Washtext_Caps")
(vlax-remove-cmd "MWST")
(vlax-add-cmd "MWST" "C:Washtext_Style")
(vlax-remove-cmd "MWSV")
(vlax-add-cmd "MWSV" "C:Washtext_Swapvalue")
(vlax-remove-cmd "MWTX")
(vlax-add-cmd "MWTX" "C:Washtext_transfer_txt2mtxt")
;ATTRIBUTE PUNCH "PUNCHATTRIBUTE"
(vlax-remove-cmd "MAA")
(vlax-add-cmd "MAA" "C:PunchAttribute")
;STRINGMAKE
(vlax-remove-cmd "MSS")
(vlax-add-cmd "MSS" "C:StringMake")
(Prompt "\nAction Recorder LISP variants loaded... Preceed Normal Command w/ \"M\" e.g. \"WF\" becomes \"MWF\" \"CHT\" becomes \"MCHT\" etc.")
(princ)
)

 

Then, at the time of initiating the Action Recorder, I start the action recording with MLF (alias I have to call the above "Macro_Lisp_Fix" function.

 

I want to punch the accept as solution button, although as I understand it, there is still actually a problem as I encounter it with the Action Recorder functionality, OR perhaps this is just a new layer of LISP handling that is by designed in AutoCAD versions AFTER 2010.  If the problem I had been encountering is considered "by design" I can click as "accept as solution" in good conscience.

 

Barring that,

 

KUDOS!  Thank You!

 

Best Regards,

Sean

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost