Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/14/2020 in all areas

  1. Another one (defun disspacify (str / regexp) (if (setq regexp (vlax-get-or-create-object "vbscript.regexp")) (progn (vlax-put-property regexp 'global actrue) (vlax-put-property regexp 'pattern " +") (vlax-invoke regexp 'replace (vl-string-trim " " str) " ") ) ) ) _$ (disspacify " This is a normal string. ") "This is a normal string." _$ [Edit]: Why not full regular expression... Plus, the dot or comma inside the string needs special treatment: (defun disspacify (str / regexp) (if (setq regexp (vlax-get-or-create-object "vbscript.regexp")) (progn (vlax-put-property regexp 'global actrue) (foreach x '( (" +[.]|[.]" . ". ");"end ." to "end. " (" +[,]|[,]" . ", ");"mid ," to "mid, " (" +" . " ");replace multiple spaces ("^ +| +$" . "");remove start and end space(s) ) (vlax-put-property regexp 'pattern (car x)) (setq str (vlax-invoke regexp 'replace str (cdr x))) ) ) ) ) _$ (disspacify " This is a double sentence ,the other one is not .This is a normal string . ") "This is a double sentence, the other one is not. This is a normal string." _$
    2 points
  2. That's the classic Robot. [ the nice one ] But this is the baddie.. [ 1998 ] Destroy the Robinsons family!!!
    1 point
  3. This behaviour is dependent on the value of the bit-coded QAFLAGS system variable in AutoCAD - if bit 1 is set, the EXPLODE command accepts selection sets when called through AutoLISP, else the EXPLODE command will only accept a single entity. As such, I would suggest: (setq qaf (getvar 'qaflags)) (setvar 'qaflags 1) (command "_.explode" "_all" "") (setvar 'qaflags qaf) FWIW, here is the documentation I have on the QAFLAGS system variable: QAFLAGS (Category: Environment) Read-only: False Data Type: Integer Stored In: Registry Default Value: 0 Comments: Undocumented Participates in the SysVarChanged Event: True Description: An internal system variable that is used by Autodesk. It stands for Quality Assurance Flags. Below are some of the values that have been discovered and tested. There are more, but no one really knows them all because each developer uses this variable differently. 0 - Commands work like normal 1 - ^C in menu cancels grips in they are active, simulating the ESCape key, allows selection sets in explode when used in AutoLISP. 2 - No pauses during the List command 4 - No Alert boxes displayed 8 - Unknown 16 - Unknown 32 - Unknown 64 - Unknown 128 - Allows for the use of Noun/Verb and Grips via. The AutoLISP command function (e.g., emulate user picks while AutoCAD is at the Command: prompt) 256 - Unknown 512 - Sets Bind type to insert in AutoCAD R14
    1 point
  4. Here is one way without the use of converting string to list then list to string and without the use of lambda. (defun weed:out:spaces ( s / n c g) (setq n "") ;; Tharwat - 14.Jul.2020 ;; (while (/= "" (setq c (substr s 1 1))) (or (= g c " ") (setq n (strcat n c))) (setq g c s (substr s 2)) ) (vl-string-trim " " n) )
    1 point
  5. The Explode command behaves slightly differently when called from Lisp. You need to get rid of the Enter (""): (defun Test_Explode () (command "_.explode" "_all") )
    1 point
×
×
  • Create New...