Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/18/2022 in all areas

  1. Changed the code again noticed it would would rev up "i" even if you selected a block that didn't match the two if statements. So put these two lines to run if the statement is true . Rather then just wrapped in the while statement. (setq i (1+ i)) (setq num (AT:NumFix (itoa i) 3))
    1 point
  2. Noooice Just wished it worked in BricsCAD. maybe it does in the newer version. added the 1+ when calculating the l
    1 point
  3. Nice. Looks like you needed the tag name in there too - see below. I was getting an extra 'X' at the end of the string, so a slight change adding 1 to the (tagstring (+ n l 1)) (defun c:INCATT3 ( / num tag pre ss1 ) (vl-load-com) (if (and (setq i (getint "\nSpecify Starting Number")) (setq replace "202XXX") (setq l (strlen replace)) ) (progn (setq num (AT:NumFix (itoa i) 3)) ;convert inter to sring before selection (while (setq ss (ssget "_+.:E:S:L" '((0 . "INSERT") (66 . 1)))) (if (and (setq tagstring (getpropertyvalue (ssname ss 0) "LINE")) (setq n (vl-string-search replace tagstring))) ;if block has ATTRIBUTE line and contains (setpropertyvalue (ssname ss 0) "LINE" (strcat (substr tagstring 1 n) "202" num (substr tagstring (+ n l 1)))) ;the string "202XXX" update to new string (princ "\"LINE\" Attribute not found or doesn't contain \"202XXX\"") ) (setq i (1+ i)) (setq num (AT:NumFix (itoa i) 3)) ) ) ) (princ) ) (defun AT:NumFix (s n) ;; Fix number string with leading zeros ;; s - Number string to fix ;; n - Number of characters for final string ;; Alan J. Thompson, 10.29.09 ;; (AT:NumFix i 3) i= 1 = 001 (if (< (strlen s) n) (AT:NumFix (strcat "0" s) n) s ) )
    1 point
  4. Yeah can't test code but was leaving out the entname so it should work now (setpropertyvalue (ssname ss 0) (strcat (substr tagstring 1 n) "202" num (substr tagstring (+ n l))))
    1 point
  5. A bit longer than MHUPP, added a couple of bits in and blatently stolen 'ATs' fixnump If you select an attribute without the XXX text in it, it will continue OK - noting it will also increment the number on the assumption you clicked the non XXX text wanting it to have the next number in it.... can change it if needed (defun c:INCATT3 ( / tag pre ss1 ) (vl-load-com) (defun LM:getattributevalue ( blk tag / enx ) ;; refer to Lee Mac Website (if (and (setq blk (entnext blk)) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk)))))) (if (= (strcase tag) (strcase (cdr (assoc 2 enx)))) (cdr (assoc 1 (reverse enx))) (LM:getattributevalue blk tag) ) ) ) (defun LM:str->lst ( str del / pos ) ;; refer to Lee Mac Website (if (setq pos (vl-string-search del str)) (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del)) (list str) ) ) (defun AT:NumFix (s n) ;; Fix number string with leading zeros ;; s - Number string to fix ;; n - Number of characters for final string ;; Alan J. Thompson, 10.29.09 ;; (AT:NumFix i 3) i= 1 = 001 (if (< (strlen s) n) (AT:NumFix (strcat "0" s) n) s ) ) (setq tag "LINE" pre "") (if (setq *num* (cond ( (getint (strcat "\nSpecify Starting Number" (if *num* (strcat " <" (itoa *num*) "> : ") ": ")))) ( *num* ))) (while (setq ss1 (ssget "_+.:E:S:L" '((0 . "INSERT") (66 . 1)))) ;; added line (setq tagstring (LM:getattributevalue (ssname ss1 0) tag)) (if (vl-some (function (lambda ( x ) (if (eq tag (vla-get-tagstring x)) ;;Modified part (progn (setq strtolst (LM:str->lst tagstring "XXX")) (if (= (length strtolst) 1) () (progn (setq prefx (nth 0 strtolst)) (setq suffx (nth 1 strtolst)) (not (vla-put-textstring x (strcat pre prefx (AT:NumFix (itoa *num*) 3) suffx))) ) ; end progn ) ' end if ) ; end progn ;end modified part ) ) ) (vlax-invoke (vlax-ename->vla-object (ssname ss1 0)) 'getattributes) ) (setq *num* (1+ *num*)) (princ (strcat tag " Attribute not found.")) ) ) ) (princ) )
    1 point
  6. ..... (setq num (AT:NumFix (itoa i) 3)) ..... Only sayin'..... I am getting an "; error: ADS request error" error, think it is from (setpropertyvalue (strcat (substr tagstring 1 n) "202" num (substr tagstring (+ n l)))) ? Not quite right but should it be more like (there was a while loop bracket out of place too): (defun c:INCATT3 ( / num tag pre ss1 ) (vl-load-com) (if (and (setq i (getint "\nSpecify Starting Number")) (setq replace "202XXX") (setq l (strlen replace)) ) (progn (setq num (AT:NumFix (itoa i) 3)) ;convert inter to sring before selection (while (setq ss (ssget "_+.:E:S:L" '((0 . "INSERT") (66 . 1)))) (if (and (setq tagstring (getpropertyvalue (ssname ss 0) "LINE")) (setq n (vl-string-search replace tagstring))) ;if block has ATTRIBUTE line and contains (setpropertyvalue (ssname ss 0) "LINE" (strcat (substr tagstring 1 n) "202" num (substr tagstring (+ n l)))) ;the string "202XXX" update to new string (princ "\"LINE\" Attribute not found or doesn't contain \"202XXX\"") ) (setq i (1+ i)) (setq num (AT:NumFix (itoa i) 3)) ) ) ) (princ) )
    1 point
  7. Crap overwritten alot of stuff but RonjonP showed me this to access block values ;; Look into get\setpropertyvalue .. pretty powerful ;; https://help.autodesk.com/view/ACD/2023/ENU/?guid=GUID-8E5913FC-09ED-4C70-AFB7-2431C062E899 (setq string or # (getpropertyvalue ename "LINE NO") getpropertyvalue doesn't work in BricsCAD so i cant test this. this should allow you to select multiple blocks at once and just step thought them. probably need to setup a way to sort them so you know what order they will be in. ;;multi select without sort (defun c:INCATT3 ( / num tag pre ss1 ) (vl-load-com) (if (and (setq *num* (getint (strcat "\nSpecify Starting Number"))) (setq num (AT:NumFix *num* 3)) (setq ss (ssget "_L" '((0 . "INSERT") (66 . 1)))) ) (foreach blk (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (if (and (setq tagstring (getpropertyvalue blk "LINE")) (setq n (vl-string-search "202XXX" tagstring))) ;if block has line no as an attribuet (setpropertyvalue (strcat (substr tagstring 1 n) "202" num (substr tagstring (+ n 6)))) ;and "202XXX" is prestent in the string (princ "\"LINE NO\" Attribute not found.") ;update value to new name ) (setq *num* (1+ *num*)) (setq num (AT:NumFix *num* 3)) ) ) (princ) ) (defun AT:NumFix (s n) ;; Fix number string with leading zeros ;; s - Number string to fix ;; n - Number of characters for final string ;; Alan J. Thompson, 10.29.09 ;; (AT:NumFix i 3) i= 1 = 001 (if (< (strlen s) n) (AT:NumFix (strcat "0" s) n) s ) )
    1 point
  8. Regardless of this is done easy way or the hard way, credit is all yours, Steven. My knowledge is very limited being a newbie in LISP world (often a user of the code than a creator). So I don't understand fully what all you mentioned above, and would not understand clearly what is required now and what it does to future requirements. Sincere apologies. But the last line makes good sense, and after trying your code, I realized that 001 indeed became 1 and that's an issue for me. Because, I am told that 001 is required to keep the 6 digits in the middle. Can this be fixed to keep 3 digits always (001, 009, 010 etc)? I didn't think this clearly earlier.
    1 point
  9. Hi Seven, Unfortunately, it doesn't work for my requirement. It asks for prefix and suffix which are different for each line. And the number of characters would also be longer if there are 3 digits at front (eg. 200-CHWS-202XXX-C1A) . The only constant is "XXX" in each line. Is there anyway the utility can just target these 3 characters? I have edited the original post to add the sample AutoCAD file for reference.
    1 point
  10. If you are wanting to change a few things you might want to look at making your line using the entmake method rather than (command "line"....) - it gives a lot more control more easily over what you draw with the LISP. You can probably also remove the setvar parts from the code, and just add them in the entmake as you make the line up See below for a quick example that will draw a line between 2 points using the getpoints function. The entmake function makes the line up and you can pass details to that as required . I've added a few details at the bottom with the codes you might find useful - these are all online of you can draw a line and use (entget(entlast)) to list that lines details, copy from there. Noting that often with entmake the order you do things is important, so keep them in the same order. (defun c:getpoints ( / pt1 pt2 ) (setq pt1 (getpoint "Point 1")) (setq pt2 (getpoint "Point 2")) (entmakeline pt1 pt2) (princ) ) (defun entmakeline ( pt1 pt2 / ) (entmake (list (cons 0 "LINE") (cons 10 pt1) (cons 11 pt2) ) ; end list ) ) ;;0 : Entity Type ;;8 : Layer ;;48 : Linetype Scale ;;62 : Colour ;;6 : Linetype ;;370: Lineweight x 100 ;;10 : Point 1 ;;11 : Point 2
    1 point
  11. I know you are wanting this ASAP and prepared to pay, just need to wait sometimes, another project I have just adding function each day and no charge. It will be finished soon paid even quicker. It can be done have you Private Mailed BeekeecZ and Hak_Z their solutions were close. I don't want to take their code and hack it then charge you.
    1 point
  12. Glad to help out. In the future test it out first before deciding it's not the solution. Most of these problems have been solved in the last 25 years .. or at least searchable.
    1 point
  13. Thankyou so much for taking the time to explain this and provide me with that code. This is exactly what I need!! I had a feeling that was what it was doing but I wasn't certain.
    1 point
  14. Both good ideas mhupp & ronjonp, saved me some time coding the bulge bit. mhupp should be able to get pline vertices then check is segment an arc then divide into chords, adding points to the pline list I need to look into Joe -burke code more, also Lee has a good pull apart pline. Sambo if not working decrease the value of the angle to say 5 degrees, suggested is 10. Even try 2.5, @5 for 90 arc = 18 points.
    1 point
  15. Try this .. solved many years ago. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/meet-joe-burke-s-tracepline-function/td-p/1592287
    1 point
  16. Wblock puts whatever you give it in a new drawing. That's all. It's not like doing a SaveAs because it builds the new file from scratch. All the features you mention are because the garbage in the old drawing doesn't get written to the new drawing.
    1 point
×
×
  • Create New...