Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/17/2024 in all areas

  1. Try this (defun c:foo ( / ss e_base pt_base n lst) (princ "\nSelect base point:") (while (null (setq ss (ssget "_+.:E:S" '((0 . "POINT")))))) (setq e_base (ssname ss 0) pt_base (cdr (assoc 10 (entget e_base))) ) (princ "\nSelect points to connect:") (setq ss (ssget '((0 . "POINT")))) (cond (ss (if (ssmemb e_base ss) (ssdel e_base ss)) (repeat (setq n (sslength ss)) (setq lst (cons (cdr (assoc 10 (entget (ssname ss (setq n (1- n)))))) lst)) ) (mapcar '(lambda (x) (entmake (list (cons 0 "LINE") (cons 10 pt_base) (cons 11 x) ) ) ) lst ) ) ) (prin1) )
    3 points
  2. Lee... Change your avatar to Mighty Mouse
    1 point
  3. If it was me I'd use something like entsel to grab the text values, then use Lee Macs string to List with a delimitator of space ( " ") to split the string up into part, reverse the list and subs the new value into what is now the first item in the list. Reverse the list again, Lee Macs List to String, and pop that back into the text. Noting that uses a similar method. For attribute blocks, VLA- functions to get and replace the text strings in the attributes rather than entsel
    1 point
  4. 1 point
  5. Tested briefly .... (vl-load-com) (defun extractNumbers (str / l rslt) (setq l (mapcar '(lambda (x) (if (and (> x 44) (< x 58) (/= x 47)) x 32) ) (vl-string->list str) ) l (mapcar '(lambda (x y) (if (not (= x y 32)) x) ) l (append (cdr l) '(32)) ) l (vl-remove-if-not '(lambda (x) (eq (type x) 'INT) x) l) l (mapcar '(lambda (x) (if (not (eq x 32)) x (list nil))) l) ) (eval (read (strcat "(setq rslt (list " (apply 'strcat (mapcar '(lambda (x) (if (not (listp x)) (chr x) " ")) l)) "))"))) ) (defun c:replacenumber ( / ss nb n ename txt rslt old_num old_list) (setq ss (ssget (list (cons 0 "*TEXT,MULTILEADER,INSERT") (cons 67 (if (eq (getvar "CVPORT") 2) 0 1)) (cons 410 (if (eq (getvar "CVPORT") 2) "Model" (getvar "CTAB"))) ) ) ) (cond (ss (initget 1) (setq nb (getint "\nEnter number to substitue: ") nb (vl-string->list (itoa nb)) ) (repeat (setq n (sslength ss)) (setq ename (vlax-ename->vla-object (cadar (ssnamex ss (setq n (1- n))))) ) (cond ((vlax-property-available-p ename 'TextString) (setq txt (vlax-get ename 'TextString)) (cond ((eq (type (setq rslt (car (extractNumbers txt)))) 'INT) (setq old_num (vl-string->list (itoa rslt)) old_list (vl-string->list txt) ) (foreach e old_num (setq old_list (vl-remove e old_list))) (vlax-put ename 'TextString (vl-list->string (append old_list nb))) ) ) ) (T (mapcar '(lambda (att) (setq txt (vlax-get-property att 'TextString)) (cond ((eq (type (setq rslt (car (extractNumbers txt)))) 'INT) (setq old_num (vl-string->list (itoa rslt)) old_list (vl-string->list txt) ) (foreach e old_num (setq old_list (vl-remove e old_list))) (vlax-put-property att 'TextString (vl-list->string (append old_list nb))) ) ) ) (vlax-invoke ename 'GetAttributes) ) ) ) ) ) ) (prin1) )
    1 point
  6. So there are differences between BricsCAD and AutoCAD... I've tested my code in BricsCAD V23 and it created sel.sets with entities from block definitions... Tested only with normal blocks - not dynamic...
    1 point
  7. With your exemple seem to do the job. (defun extractNumbers (str / l rslt) (setq l (mapcar '(lambda (x) (if (and (> x 44) (< x 58) (/= x 47)) x 32) ) (vl-string->list str) ) l (mapcar '(lambda (x y) (if (not (= x y 32)) x) ) l (append (cdr l) '(32)) ) l (vl-remove-if-not '(lambda (x) (eq (type x) 'INT) x) l) l (mapcar '(lambda (x) (if (not (eq x 32)) x (list nil))) l) ) (eval (read (strcat "(setq rslt (list " (apply 'strcat (mapcar '(lambda (x) (if (not (listp x)) (chr x) " ")) l)) "))"))) ) (defun c:replacenumber ( / ss nb n ename dxf_ent txt old_num old_list) (setq ss (ssget '((0 . "*TEXT")))) (cond (ss (initget 1) (setq nb (getint "\nEnter number to substitue: ") nb (vl-string->list (itoa nb)) ) (repeat (setq n (sslength ss)) (setq ename (ssname ss (setq n (1- n))) dxf_ent (entget ename) txt (cdr (assoc 1 dxf_ent)) ) (setq old_num (vl-string->list (itoa (car (extractNumbers txt)))) old_list (vl-string->list txt) ) (foreach e old_num (setq old_list (vl-remove e old_list))) (entmod (subst (cons 1 (vl-list->string (append old_list nb))) (assoc 1 dxf_ent) dxf_ent)) ) ) ) (prin1) )
    1 point
  8. You are itterating the block definitions? Not sure you can built a selectionset from this. You can make a block name list first and use that as a base for ssget filter. Between processing the different blocks set ss to nil and call garbage collection (GC) a few times before moving on to next block. This can release memory and prevent crashing. First wblock * (entire drawing) copies valid objects only in case there are a few gremlins in there, sort of audit. When going through ssget list per block , you could save IP in list (reset list for next block name) and if IP is member of list (maybe with fuzz) , you know this block is hanky panking on top of (or under) another block and you can entdel this block. What do you do when you have a big wife , euh problem : you split it up in smaller problems (not talking about children here because they only make your problem bigger haha) , anyways you could split up your drawing into lets say 4 drawings first so each drawing is easier to handle. After processing rejoin & rejoyce. just a few thoughts... ps. Just remebered a while back I wrote a lisp to wblock all blocks (from all drawings in a folder I think) to another folder so I could see what blocks a vendor was using. Then go through them and change if needed and redefine / re-insert them back into the drawings. Not sure if this is the right lisp but you're welcome to try it (on a copy so you can't blame the dragon). Maybe you can use overkill in a script to clean the blocks first. It still may be a big job but if the drawing is worth it... RlxDbxWblock.lsp
    1 point
  9. you could try this one but haven't used or tested it much and it is limited to one block name at the time. Had on my wish list to make option to make something like , hey appie , this is my drawing folder and this this where I have my new blocks , go get'm all... but unfortunately haven't got the time to do so at this moment. Use at own risk and do so first on a few test drawings. If it works , fine , if it doesn't ... can't do anything about it at this time.
    1 point
  10. You can either extract the coordinates with vla-get-coordinates and combine the list into groups of 3 or entnext through the selected ename (using entsel), create a list of coordinates (X,Y,Z), sort by Z value, then you can easily take the highest and lowest value and label accordingly. eg. HighLowLabel.zip
    1 point
×
×
  • Create New...