Jump to content

Search the Community

Showing results for tags 'string'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • CADTutor
    • News, Announcements & FAQ
    • Feedback
  • AutoCAD
    • AutoCAD Beginners' Area
    • AutoCAD 2D Drafting, Object Properties & Interface
    • AutoCAD Drawing Management & Output
    • AutoCAD 3D Modelling & Rendering
    • AutoCAD Vertical Products
    • AutoCAD LT
    • CAD Management
    • AutoCAD Bugs, Error Messages & Quirks
    • AutoCAD General
    • AutoCAD Blogs
  • AutoCAD Customization
    • The CUI, Hatches, Linetypes, Scripts & Macros
    • AutoLISP, Visual LISP & DCL
    • .NET, ObjectARX & VBA
    • Application Beta Testing
    • Application Archive
  • Other Autodesk Products
    • Autodesk 3ds Max
    • Autodesk Revit
    • Autodesk Inventor
    • Autodesk Software General
  • Other CAD Products
    • BricsCAD
    • SketchUp
    • Rhino
    • SolidWorks
    • MicroStation
    • Design Software
    • Catch All
  • Resources
    • Tutorials & Tips'n'Tricks
    • AutoCAD Museum
    • Blocks, Images, Models & Materials
    • Useful Links
  • Community
    • Introduce Yourself
    • Showcase
    • Work In Progress
    • Jobs & Training
    • Chat
    • Competitions


  • Programs and Scripts
  • 2D AutoCAD Blocks
  • 3D AutoCAD Blocks
  • Images
    • Backgrounds

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...

Found 10 results

  1. I'm trying to find the latest revision from a list of revisions. The revisions start with A,B,C... Z, AA, AB, AC...ZZ, AAA, AAB, AAC... Then proceed to numbers 0, 1, 2, 3, etc. Any help would be appreciated! (setq testCases (list "A" "AA" "AB" "BD" "AZ" "ZZ" "ZZZ" "11" "10" "9" "2" "1" "0" "Z" "X" "D" "C" "B")) (setq testCases (vl-sort testCases '(lambda ( b a / x y ) (setq x (read a) y (read b)) (cond ( (and (numberp x) (numberp y)) (< x y)) ( (numberp y)) ( (numberp x) nil) ( (< a b)) ) ) ) ) (foreach test testCases (progn (princ "\n") (princ test) ) ) ;Currently produces the following reverse-alphabetical sequence: ;11, 10, 9, 2, 1, 0, ZZZ, ZZ, Z, X, D, C, BD, B, AZ, AB, AA, A ;Desired sequence: ;11, 10, 9, 2, 1, 0, ZZZ, ZZ, BD, AZ, AB, AA, Z, X, D, C, B, A
  2. ;; [INSERT INCEPTION SOUND EFFECTS HERE] ;; Preface: I've built a lisp routine that generates a script. The script then runs a SECOND lisp routine on a series of drawings. ;; I'm having serious trouble passing information from the first lisp routine to the second lisp routine. ;; The first lisp routine uses a DCL dialog box to gather user information, and the second lisp routine needs to apply this information to each drawing in a set. ;; I have assembled the information into a list of strings, which I'd like to pass as an argument into the second lisp (unless there's an easier way someone can share with me). ;; To do this, I've created the _StringifyList function, which creates a new list declaration string that gets written to the script file. ;; So here's the problem: ;; The strings in the arguments may contain quotes or backslashes since they are user entered. ;; The vl-string-translate commands I've added aren't properly appending extra backslash escape characters to make up for this. ;; Try running this example: (defun C:ListTest ( / *error* simpleList simpleListString) ;Return error descriptions to command line in the event of an error (defun *error* (/) (princ "\nInternal error") ) ;test strings are A,B,C ;to create a list: (setq simpleList (list "A" "B" "C")) (princ "simpleList: ") (princ simpleList) (princ "\n") ;result is not what we need: ;simpleList: (A B C) ;now lets wrap it with the stringify function: (setq simpleListString (_StringifyList simpleList)) (princ (strcat "simpleListString: " simpleListString "\n")) ;result is good, it can be written to a script as an argument now: ;simpleListString: (list "A" "B" "C") ;how about something more complicated though? ;test strings are one"quote, this\that, three"""quotes ;to create a list: (setq complexList (list "one\"quote" "this\\that" "three\"\"\"quotes")) (setq complexListString (_StringifyList complexList)) (princ (strcat "complexListString: " complexListString "\n")) ;result is bad. quotes have been replaced with backslashes, and backslashes haven't been duplicated. ;complexListString: (list "one\quote" "this\that" "three\\\quotes") ;what the result should look like (I think): ;complexListString: (list "one\"quote" "this\\that" "three\"\"\"quotes") (princ) ) ;; _StringifyList - plackowski ;; takes a list of strings and converts them to a declaration of a list of strings. ;; lst - [lst] A list of strings, like ("A" "B" "C") ;; str - [str] Output string in the format "(list "A" "B" "C")" (defun _StringifyList (lst / str) (setq str "(list") (foreach item lst ;any backslashes should be replaced with double slashes: \ -> \\ (setq item (vl-string-translate "\\" "\\\\" item)) ;any quotes in the string should be replaced with slash quotes to escape them: \" -> \\\" (setq item (vl-string-translate "\\\"" "\\\\\\\"" item)) (setq str (strcat str " \"" item "\"")) ) (setq str (strcat str ")")) )
  3. Hi, I am running into problems with my program when I try to use the output from the "LM:directoryfiles" function. If I try to use the output from the "LM:directoryfiles" function (findjgw) I am getting the following error... error: bad argument type: (or stringp symbolp): ("L:\\DESIGN\\2018\\2018-290 Atkinson Crescent, ALDINGA BEACH\\Work in Progress CAD\\References CAD\\2018-290 Image\\2018-290 Image.jgw") (findjgw) returns the following "L:\\DESIGN\\2018\\2018-290 Atkinson Crescent, ALDINGA BEACH\\Work in Progress CAD\\References CAD\\2018-290 Image\\2018-290 Image.jgw" and if I enter this actual text string in my code it works, but it wont when referring to the variable (findjgw). Is it because I am trying to use a list as a string? If I only use the first element of a list are they not the same thing? Snippet that seems to be thew problem... ; Search Project "References CAD" Folder for ".jgw" files and Count how many... (setq rcpath (strcat sfpath "Work in Progress CAD\\References CAD\\")) (setq findjgw (LM:directoryfiles rcpath "*.jgw" T)) (setq countjgw (length findjgw)) (cond ( (= countjgw 1) (princ "\nOnly 1 Georeferenced Aerial Image exists in 'References CAD folder'") (setq jpgname (vl-string-subst "jpg" "jgw" findjgw)) (setq intFileDia (getvar "filedia")) (setvar "filedia" 0) (command "mapiinsert" jpgname "") (command "zoom" "e") (setvar "filedia" intFileDia) (princ "\nGeoreferenced Aerial Imagery Inserted...") ) ( (> countjgw 1) (alert "More than 1 Georeferenced Aerial Image exists in 'References CAD folder'...\nPlease select file to insert...") (command "mapiinsert") (princ) ) (t nil) );End Cond I will attach the full copy also. Regards, Ross. ONK Mapiinsert 4.lsp
  4. I am trying to script a counter of specific strings. How can I select all occurrences of text that has a specific value? I cannot use filter or quickselect, and I cannot get selection sets to find specified values. Any help would be greatly appreciated. I am using ACADE 2015.
  5. Hi everyone, I am a software developer , i program in C# C++ and Java, but lately i have been given a task to help out our engineering department to write some code + script to fix cad prints which they have issues with. our problem is we use a third party application which generates an AutoCad drawing. this third part application sets the dimscale to 1:000; But the drawing's title block scale attribute has has the correct scale value. My task was to write code in lisp and our script to automate this process; which will requires the program to read the value for the scale attribute and apply it to the drawing dimscale. after reading some tutorials and searching the web i cam across some functions that did most of my task...Thanks to this community and its forums. my main function that reads the attribute value i got from on of the threads as shown below: (defun c:AttLst (/ ss eLst bEnt aEnt aEntLst aVal blkLst) (vl-load-com) (if (setq ss (ssget "X" (list (cons 0 "INSERT") (cons 66 1) (if (getvar "CTAB") (cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE"))))))) (progn (setq eLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) (foreach e eLst (setq bEnt (cdr (assoc 2 (entget e))) aEnt (entnext e)) (while (= "ATTRIB" (cdr (assoc 0 (setq aEntLst (entget aEnt))))) (if (= (cdr (assoc 2 aEntLst)) "SCALE") (progn (setq aVal (cdr (assoc 1 aEntLst)) blkLst (cons (cons bEnt aVal) blkLst)))) (setq aEnt (entnext aEnt))))) (princ "\n<!> No Attributed Blocks Found <!>")) (alert (vl-princ-to-string blkLst)) (princ)) This function works great when the scale value has no white spaces; but when there is white spaces it only returns the right side of the scale value example 1 : SCALE 1:5 ==> Result = (( TitleBlockName. 1:5)) example 2 : SCALE 1 : 10 ==> Result = (( TitleBlockName. 1 : )) as you see in example 2 the return value is missing the right side value can you please help me with this issue to figure out why its returning the left side only?
  6. When I generate a new drawing it creates a text file with information. Autocad updates text automatically from this file using specific layers that the string is on in the drawing. Depending on what layer a string is on, that will determine what information it is updated with. With that being said, it will not update ATTRIBUTES within a BLOCK. Can someone help. I am willing to discuss and assist with figuring this out. I will be automating some information for my titleblocks and ALL of our titleblocks are blocked with attributes. Here is the code used to update the info (defun uinfo () (princ "\nUpdating Drawing Information...") (if (= found 1) (progn (setq dummy (read-line infile)) (setq desc (read dummy)) (setq dummy (read-line infile)) (setq drawing (read dummy))) (progn (setq desc '(1 . "- NEW EQUIPMENT -")) (setq drawing '(1 . "- UNASSIGNED -")))) (setq sset (ssget "X" (list (cons 0 "TEXT") (cons 8 "TITLE")))) (setq lp 0) (while (< lp (sslength sset)) (setq ent (entget (ssname sset lp))) (setq entinfo (cdr (assoc 1 ent))) (if (= (substr entinfo 1 4) "Desc") (entmod (subst desc (assoc 1 ent) ent))) (if (= (substr entinfo 1 4) "Draw") (entmod (subst drawing (assoc 1 ent) ent))) (if (= (substr entinfo 1 3) "Dwg") (entmod (subst drawing (assoc 1 ent) ent))) (if (= (substr entinfo 1 4) "DESC") (entmod (subst desc (assoc 1 ent) ent))) (if (= (substr entinfo 1 4) "DRAW") (entmod (subst drawing (assoc 1 ent) ent))) (if (= (substr entinfo 1 3) "DWG") (entmod (subst drawing (assoc 1 ent) ent))) (setq lp (1+ lp))) (setq sset nil) (setq lp nil) (setq sset (ssget "X" (list (cons 0 "TEXT") (cons 8 (strcat tcircuit "-EQMRK"))))) (setq lp 0) (if (/= sset nil) (while (< lp (sslength sset)) (setq ent (entget (ssname sset lp))) (setq entinfo (cdr (assoc 1 ent))) (if (= (substr entinfo 1 4) "Desc") (entmod (subst desc (assoc 1 ent) ent))) (if (= (substr entinfo 1 4) "Draw") (entmod (subst drawing (assoc 1 ent) ent))) (if (= (substr entinfo 1 3) "Dwg") (entmod (subst drawing (assoc 1 ent) ent))) (if (= (substr entinfo 1 4) "DESC") (entmod (subst desc (assoc 1 ent) ent))) (if (= (substr entinfo 1 4) "DRAW") (entmod (subst drawing (assoc 1 ent) ent))) (if (= (substr entinfo 1 3) "DWG") (entmod (subst drawing (assoc 1 ent) ent))) (setq lp (1+ lp)))) (princ "Done.") (prin1)) Here is the actual routine used to provoke the update of all information in the drawing based on its respective layer. (defun C:UPDATE () (setvar "CMDECHO" 0) (setvar "MENUCTL" 0) ;; (command "._snap" "0.03125") (command "plinewid" "0.0") (if (null filename) (setq filename (getstring "\nPath and name of update file: "))) (if (null tcircuit) (progn (C:EQUIP2)) (progn (makenames tcircuit) (checklayers tcircuit))) (if (null tcircuit) (progn (princ "\nCurrent name has not been established") (princ "\nplease type EQUIP and establish current equip. or make new")) (progn (openfile) (seek-tcircuit) (if (= (getvar "userr1") 0.0) (setvar "userr1" 3.0)) (if (= (getvar "userr2") 0.0) (setvar "userr2" 1.0)) (if (ssget "X" (list (cons 8 "CIRCUIT-INFO") (cons 0 "TEXT"))) (uinfo) (repeat 2 (read-line infile))) (if (ssget "X" (list (cons 8 "TITLE") (cons 0 "TEXT"))) (udates) (repeat 2 (read-line infile))) ;; (uinfo) ;; (udates) (if (= found 1) ;; (progn (udp) (uext) (uldar) (uvalve)) (princ "\nNO INFORMATION TO UPDATE")) (closefile))) (command "._-layer" "s" PIPING "") (princ)) I need to add to the code so that it will update the defined text strings of attributes within a block. IF you have any input or any questions I would appreciate everything.
  7. Hi All, as most of you know, (vl-registry-read) is a good function to get data out of windows registry. It works nice for string and decimal number data, but not works correct for hexadecimal (or binary) data. For example, if you issue this: (vl-registry-read "[b]HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RecentDocs[/b]" "[b]MRUListEx[/b]") you will find '(3) or something similar as the result, but the data exported by Windows "REGEDIT" command on my PC is as seen below: How is it possible to get hexadecimal (binary) data from registry. (In the following step, I guess I can convert binary data to strings.) Any help, clues or suggestions are greatly appreciated.
  8. Hi guys, I'm a new member as you can see, but i've been coming here for many years to find information about lisp. I've done a thread search and haven't located a solution to my issue. I am self taught, so there is only so far i can go without getting the experts involved. My question (i think) is very similar to this thread http://www.cadtutor.net/forum/showthread.php?31762-Need-help-extracting-attribute-values-in-Lisp What i need to do is: 1. Extract two attribute values (Tags are "DRGNO" "DRGREV") from an inserted block (Block name "DRG_SHEET.dwg"). 2. Build a string in the Command Line using those 2 values. It seems very simple, i just haven't fully wrapped my head around the list manipulation tools in AutoLISP. Any help would be greatly appreciated. Thanks, Scott.
  9. Hey everyone. Im having a bit of trouble constructing a string. I have my code working perfectly except for one little thing. I want the middle part of my string to be a variable, set by the user earlier in the code, or reading another USER variable. Here is my code so far: (defun C:titld (/ strRevv ) ;' (vl-load-com) (SETQ RV (GETVAR "USERI5")) (IF (= RV 0)(setVAR "USERI5" (getint "\nEnter Current Revision Number: "))) (setq pt (getpoint "\Select Insertion Point: ")) (setq strRevv (getvar "useri5")) (setq date (strcat "%<[url="file://acsm/"]\\AcSm[/url] SheetSet.REV " "04" " DATE [url="file://f/"]\\f[/url] \"%tc1\">%")) (setq desc (strcat "%<[url="file://acsm/"]\\AcSm[/url] SheetSet.REV " "04" " DESCRIPTION [url="file://f/"]\\f[/url] \"%tc1\">%")) (setq initial (strcat "%<[url="file://acsm/"]\\AcSm[/url] SheetSet.REV " "04" " INITIALS [url="file://f/"]\\f[/url] \"%tc1\">%")) ;(setq date (strcat "rev " strrevv " INITIALS")) (COMMAND "-insert" "rev1t40-d" pt "" "" "" strrevv date desc initial)() ) Notice in each of the date, desc, initial lines there is the "04". What i would like to be able to do is use the value stored in the strRevv variable and make the string out of that number. Is this even possible? Thanks in advance for your time!
  10. Hi, I'm attempting to modify Fixo's code at bottom to read data from an excel spreadsheet that's formatted a bit differently than assumed by the code. The code here assumes X, Y, and Z scale each live in a separate exel column/cell. However, I have existing spreadsheets where these dimensions were entered as a text string in a single cell. For example, the cell might read 6x5.5x24. The only constant is the "x" between the dimensions. The text numbers might be one, two or even three characters and may or may not include decimals. My thought is to modify these lines below to somehow check the same string for the X's and truncate according its position to extract the desired X, Y or Z value. But, I don't know enough yet to even know if this is possible. xscale (atof (vl-princ-to-string (nth 5 item))) yscale (atof (vl-princ-to-string (nth 6 item))) zscale (atof (vl-princ-to-string (nth 7 item))) Failing this, I'll make a second version of the existing spreadsheets and have users copy data into new columns formatted to work with the existing code. Many thanks! ;;;---------------------------------------------------------------------------; ;;; ;;; getexel.lsp ;;; ;;; based on code posted by "fixo" on [url]http://forums.augi.com/showthread.php?t=112689&highlight=blocks+excel[/url] ;;; This lisp is used to insert a block multiple times based on coordinates and scale factors listed in an excel spreadsheet ;;; Data in spreadsheet must follow this format: ;;; first row is headers/labels for data ;;; cola-empty, colb-x coord, colc-y coord, cold-z coord, colf-width/x scale, colg-depth/y scale, colh-height/z scale, ;;; coli-layer destination name, colj-equip tag number. ;;; ;;;---------------------------------------------------------------------------; ;;; ;;; DESCRIPTION ;;; ;;; Configure AutoCAD ;;; ;;;****************************************************** ;;; Section 1 ;;;****************************************************** ;;; ;;; --- Load Visual Lisp Support ;;; (VL-LOAD-COM) ;;;****************************************************** ;;; Section 2 ;;;****************************************************** ;;; read used range from Excel ;;; (defun getexcelinfo (Wbk ShtNum / Sht UsdRange ExcData) (setq Sht (vl-catch-all-apply 'vlax-get-property (list (vlax-get-property Wbk "Sheets") "Item" ShtNum ) ) ) (setq UsdRange (vlax-get-property Sht "UsedRange") ExcData (vlax-safearray->list (vlax-variant-value (vlax-get-property UsdRange "Value") ) ) ) (setq ExcData (mapcar (function (lambda (x) (mapcar 'vlax-variant-value x))) ExcData ) ) ExcData ) ;;;****************************************************** ;;; Section 3 ;;;****************************************************** (defun C:getexcel (/ *error* acsp adoc aexc att1 att2 att3 att4 attribs block_data blockname block_obj dwgpath layer rot x xlbook xlbooks xlpath xscale y yscale z zscale) (defun *error* (msg) (vl-bt) (if (vl-position msg '("console break" "Function cancelled" "quit / exit abort" ) ) (princ "Error!") (princ msg)) (vla-endundomark adoc) (vl-exit-with-value "Program bombed, sorry") ) (if (setq xlpath (getfiled "* Select Excel File To Read Data*" "" "xlsx" 4) ) (progn (setq aexc (vlax-get-or-create-object "Excel.Application") xlbooks (vlax-get-property aexc "Workbooks")) (setq xlbook (vlax-invoke-method xlbooks "Open" xlpath)) (setq block_data (getexcelinfo xlbook 1));<-- 1 is excel sheet number, change to suit (setq block_data (vl-remove-if-not (function (lambda (x) (car x))) block_data)) (setq block_data (cdr block_data)) (vl-catch-all-apply (function (lambda () (vlax-invoke-method xlbook "Close" :vlax-false))) ) (mapcar (function (lambda (x) (vl-catch-all-apply (function (lambda () (progn (if x (vlax-release-object x))))))) ) (list xlbook xlbooks aexc) ) (setq aexc nil) (gc) (gc) (setq dwgpath (getfiled "* Select Drawing With Block To Insert *" "" "dwg" 4) ) (setq blockname (vl-filename-base dwgpath)) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (setq acsp (vla-get-block (vla-get-activelayout adoc))) (vla-startundomark adoc) (vl-catch-all-apply (function (lambda () (progn (setq block_obj (vlax-invoke-method acsp 'InsertBlock (vlax-3d-point '(0 0 0)) dwgpath 1 1 1 0 ) ) (vla-delete block_obj) (vlax-release-object block_obj)))) ) ;; I know nothing what is data format in your Excel ;; thus I have added extrafluous convertion of them (foreach item block_data (setq x (atof (vl-princ-to-string (nth 1 item))) y (atof (vl-princ-to-string (nth 2 item))) z (atof (vl-princ-to-string (nth 3 item))) rot (atof (vl-princ-to-string (nth 4 item))) xscale (atof (vl-princ-to-string (nth 5 item))) yscale (atof (vl-princ-to-string (nth 6 item))) zscale (atof (vl-princ-to-string (nth 7 item))) layer (vl-princ-to-string (nth 8 item)) att1 (vl-princ-to-string (nth 9 item)) att2 (vl-princ-to-string (nth 5 item)) att3 (vl-princ-to-string (nth 6 item)) att4 (vl-princ-to-string (nth 7 item)) ) (setq block_obj (vlax-invoke-method acsp 'InsertBlock (vlax-3d-point (list x y z)) dwgpath xscale yscale zscale rot) ) (if (tblsearch "layer" layer) (vla-put-layer block_obj layer) (princ (strcat "\nLayer " "\"" layer "\"" " does not exist")) ) (setq attribs (vlax-invoke block_obj 'GetAttributes)) (foreach att attribs (cond ((eq "EQ-TAG" (vla-get-tagstring att));<--"EQ-TAG" is the first tag (vla-put-textstring att att1)) ((eq "EQ-WIDTH" (vla-get-tagstring att));<--"EQ-WIDTH" is the second tag (vla-put-textstring att att2)) ((eq "EQ-DEPTH" (vla-get-tagstring att));<--"EQ-DEPTH" is the THIRD tag (vla-put-textstring att att3)) ((eq "EQ-HGHT" (vla-get-tagstring att));<--"EQ-HGHT" is the FOURTH tag (vla-put-textstring att att4)) ;<-- add other tags here by the same way as above (T nil) ) ) ) ) ) (*error* nil) (prin1) ) (prompt "\n\t\t>>>\tType getexcel to execute\t<<<") (prin1) (vl-load-com)~'J'~
  • Create New...