Jump to content

pmxcad

Members
  • Content count

    249
  • Joined

  • Last visited

Community Reputation

10 Good

About pmxcad

  • Rank
    Rising Star
  • Birthday 10/08/1965

Personal Information

  • Real Name
    Jaap
  • Location
    Netherlands
  • Interests
    photography, Panorama photography, virtual tours

My Work

  • Occupation
    CAD designer in safety
  • Discipline
    Electrical
  • Discipline details
    Safety (fire,access control, cctv, intercom, evacuation, fire panels)

My Software

  • Main CAD Product
    AutoCAD
  • Current Product Version
    2014
  • First AutoCAD Version
    AutoCAD R12
  • Other Applications
    Photoshop, PTGUI

My Computer

  • Operating System
    win 10
  • Computer
    HP Z420
  • Monitor
    2x
  • CPU
    xenon
  • RAM
    32G
  1. pmxcad

    INCATT according a list

    It is for numbering components. These are connected to the modules in cabinet 01 and 02. The first module (main module) with the address 1000 has only 6 inputs and the I / O modules have 12. So when the first one is full, it goes on with the I / O module 1100. And if it is full, it goes on with 1200 .... 1300 .... etc. Usually it is limited to 3 I / O modules but some times 7 (I / O 1800). The drawing is just an example. In real life, several types of components are used. I hope you get a little insight from my intention. test.dwg
  2. pmxcad

    INCATT according a list

    Hi BIGAL, I am not going to succeed, would not know which list I should use. (red top) and where to place. And do I have to delete that one line and put your code there? (red) ;================================================== (defun c:INCATT ( / f str i f tag num pre post OOv ; *StartStr121007 ; *IncreaseN121007 [color=red] ;--------------- list PmxCAD -------------------------------------------------------------------------------------------------------------- (setq lst '(1001 1002 1003 1004 1005 1006 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 );lst );setq this one? ;(setq lst '((1001 1 6)(1201 1 12)(1301 1 12)(1401 1 12)(1501 1 12)(1601 1 12)(1701 1 12)(1801 1 12)); or this one? )[/color] ;----------------------------------------------------------------------------------------------------------------------------- HUE:DivideNum HUE:memoVar HUE:stringsubst HUE:StringCal HUE:start HUE:end _divideStr ) ;------------------------------------------------------------------------- ; Sub Function ;------------------------------------------------------------------------- (defun HUE:DivideNum ( str / lst s m v1 v2 i j c _NumP _Cal) (defun _NumP ( x ) (<= 48 x 57)) (defun _Cal ( ty v ) (set v (cons (vl-list->string (reverse (eval ty))) (eval v))) (set ty nil) ) (setq lst (vl-string->list str) i -1 j -1) (repeat (length lst) (setq c (nth (setq i (+ i 1)) lst)) (cond ( (_NumP c) (setq s (cons c s) ) (cond ( m (_Cal 'm 'v1) (setq j (+ 1 j))))) ( (and (= c 46) (> i 0) (_NumP (nth (- i 1) lst)) (_NumP (nth (+ i 1) lst))) (setq s (cons c s)) ) (t (setq m (cons c m)) (cond ( s (_Cal 's 'v1) (setq v2 (cons (setq j (+ 1 j)) v2)))) ) ) ) (cond ( m (_Cal 'm 'v1)) ( t (_Cal 's 'v1) (setq v2 (cons (setq j (+ 1 j)) v2))) ) (list (reverse v1) (reverse v2)) ) ;------------------------------------------------------------------------- ; Sub Function ;------------------------------------------------------------------------- (defun HUE:memoVar ( va f m s / v ) (setq v (if (member (eval va) '(nil "")) s (eval va))) (mapcar 'princ (list "\n" m " <" v "> : ")) (set va ( f )) (if (member(eval va) '(nil "")) (set va v)) (eval va) ) ;------------------------------------------------------------------------- ; Sub Function ;------------------------------------------------------------------------- (defun HUE:stringsubst ( new old str / l i ) (setq l (strlen new) i 0) (while (setq i (vl-string-search old str i)) (setq str (vl-string-subst new old str i) i (+ i l)) ) str ) ;------------------------------------------------------------------------- ; Sub Function ;------------------------------------------------------------------------- (defun HUE:StringCal ( str f n / _GetPP data1 data2 num i DIMZIN ) (defun _GetPP ( str / lst l post pre flag ) (setq lst (vl-remove 45 (vl-string->list str)) post (if (setq l (member 46 lst)) (- (length l) 1) 0) pre (if (setq l (member 46 (reverse lst))) (- (length l) 1) (length lst)) flag (minusp (atof str)) ) (list pre post flag) ) (setq DIMZIN (getvar 'DIMZIN)) (setvar 'DIMZIN 0) (setq data1 (_GetPP str) num (vl-string->list (rtos (f (atof str) n) 2 (cadr data1))) data2 (_GetPP (vl-list->string num)) num (vl-remove 45 num) ) (setvar 'DIMZIN DIMZIN) (if (< 0 (setq i (- (car data1) (car data2)))) (repeat i (setq num (cons 48 num))) ) (if (< 0 (setq i (- (cadr data1) (cadr data2)))) (repeat i (setq num (append num '(48)))) ) (if (caddr data2) (setq num (cons 45 num))) (vl-list->string num) ) ;------------------------------------------------------------------------- ; Sub Function ;------------------------------------------------------------------------- (defun HUE:start( lst ) (vla-startundomark (HUE:end nil)) (list lst (mapcar 'getvar lst)) ) ;------------------------------------------------------------------------- ; Sub Function ;------------------------------------------------------------------------- (defun HUE:end ( d / doc ) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (and (cadr d) (mapcar 'setvar (car d) (cadr d))) (if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-endundomark doc)) doc ) ;------------------------------------------------------------------------- ; Sub Function ;------------------------------------------------------------------------- (defun _divideStr ( str / data i j k pre post ) (setq data (HUE:DivideNum str) k (last (cadr data)) j 0 pre "" post "" ) (foreach s (car data) (cond ( (< j k) (setq pre (strcat pre s))) ( (> j k) (setq post(strcat post s))) ( (= j k) (setq i s)) ) (setq j (+ 1 j)) ) (list pre i post) ) ;------------------------------------------------------------------------- ; Error Function ;------------------------------------------------------------------------- (defun *error* (s) (if OOv (HUE:End OOv)) (princ s) ) ;----------------------------------------------------------------------------------- ; Main Function ;----------------------------------------------------------------------------------- [color=red] ;(setq str (HUE:MemoVar '*StartStr121007 getstring "StartString " "100");----------------------------------------- [/color] [color=red] ;--------------- Example code BIGAL---------------------------------------------------------------------------------------- ;oflist ((1001 1 5)(1201 1 12)(1300 2 4)) (setq y 0) (repeat (length oflist) (setq stnum (nth y (nth 0 oflist)) (setq inc (nth y (nth 1 oflist)) (setq howmany (nth y (nth 2 oflist)) (repeat howmany do your attinc now ..... ...... ) ; repeat howmany (setq y (+ y 1)) ) ; repeat ;-----------------------------------------------------------------------------------------------------------------------------[/color] i 1 OOv (HUE:Start '(DIMZIN)) ) (and (vl-string-search "," str) (setq str (HUE:StringSubst "." "," str) f t) ) (mapcar 'set '(pre num post) (_DivideStr str)) (setq tag "TEXT1" num (HUE:StringCal num - i) ) (setvar 'ERRNO 0) (setvar 'DIMZIN (while (= 0 (getvar 'ERRNO)) (and (setq o (ssget "_+.:E:S:L" '((0 . "INSERT") (66 . 1)))) ;(C:PUTA);------------------------------------------------------put locationcode----------------------------------- (vl-some '(lambda ( att ) (if (= tag (vla-get-tagstring att)) (progn (setq num (HUE:StringCal num + i) str (strcat pre num post) ) (if f (setq str (HUE:StringSubst "," "." str))) (vla-put-textstring att str) ) ) ) (vlax-invoke (vlax-ename->vla-object (ssname o 0)) 'getattributes) ) ) ) (HUE:End OOv) (princ) )(vl-load-com)
  3. pmxcad

    INCATT according a list

    Wow hanhphuc, that works. I only changed (setq x 1000) to (setq x 1001) to start with 1001. But how can I apply it to the attinc.lsp?
  4. pmxcad

    INCATT according a list

    I think I should use (nth 0 lst) to read my example list and (nth 0 (nth 0 lst)) to read the example of BIGAL, is that correct?
  5. pmxcad

    INCATT according a list

    Well, it's not that simple for me. But I think this is a counter. It starts at 1301 to 1312. The (1 + n) is the counter and the (+ 100 n) increases the value by 100 and the (repeat 12 is repeated 12 times. I managed to get a bit out of that, but I do not understand (getpoint) and print.
  6. pmxcad

    INCATT according a list

    I have been playing around to make a list. I made the following. (defun c:test1 () (setq lst '(1001 1002 1003 1004 1005 1006 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 ) ) (princ lst) ) Is a lot of typing and it is not as advanced as yours but also works. I've also been playing around with the example of BIGAL. (defun c:test2 () (setq lst '((1001 1 6)(1201 1 12)(1301 1 12)(1401 1 12)(1501 1 12)(1601 1 12)(1701 1 12)(1801 1 12)) ) ) But I really would not know how to apply this in the INCATT lisp. Can someone help me with that? Thanks in advance, PmxCAD
  7. Hi, I have the following lisp to increase an attribute. Works well, but is it possible to do this according to a list? What I would like is the following: start at number 1001 then next 1002, 1003, 1004, 1005 & 1006. and then after the 1006 continue with 1101 to 1112 and then continue with 1201 to 1212 And so on with 1301 to 1312 1401 to 1412 1501 to 1512 1601 to 1612 1701 to 1712 1801 to 1812 ;================================================== (defun c:INCATT ( / f str i f tag num pre post OOv ; *StartStr121007 ; *IncreaseN121007 HUE:DivideNum HUE:memoVar HUE:stringsubst HUE:StringCal HUE:start HUE:end _divideStr ) ;------------------------------------------------------------------------- ; Sub Function ;------------------------------------------------------------------------- (defun HUE:DivideNum ( str / lst s m v1 v2 i j c _NumP _Cal) (defun _NumP ( x ) (<= 48 x 57)) (defun _Cal ( ty v ) (set v (cons (vl-list->string (reverse (eval ty))) (eval v))) (set ty nil) ) (setq lst (vl-string->list str) i -1 j -1) (repeat (length lst) (setq c (nth (setq i (+ i 1)) lst)) (cond ( (_NumP c) (setq s (cons c s) ) (cond ( m (_Cal 'm 'v1) (setq j (+ 1 j))))) ( (and (= c 46) (> i 0) (_NumP (nth (- i 1) lst)) (_NumP (nth (+ i 1) lst))) (setq s (cons c s)) ) (t (setq m (cons c m)) (cond ( s (_Cal 's 'v1) (setq v2 (cons (setq j (+ 1 j)) v2)))) ) ) ) (cond ( m (_Cal 'm 'v1)) ( t (_Cal 's 'v1) (setq v2 (cons (setq j (+ 1 j)) v2))) ) (list (reverse v1) (reverse v2)) ) ;------------------------------------------------------------------------- ; Sub Function ;------------------------------------------------------------------------- (defun HUE:memoVar ( va f m s / v ) (setq v (if (member (eval va) '(nil "")) s (eval va))) (mapcar 'princ (list "\n" m " <" v "> : ")) (set va ( f )) (if (member(eval va) '(nil "")) (set va v)) (eval va) ) ;------------------------------------------------------------------------- ; Sub Function ;------------------------------------------------------------------------- (defun HUE:stringsubst ( new old str / l i ) (setq l (strlen new) i 0) (while (setq i (vl-string-search old str i)) (setq str (vl-string-subst new old str i) i (+ i l)) ) str ) ;------------------------------------------------------------------------- ; Sub Function ;------------------------------------------------------------------------- (defun HUE:StringCal ( str f n / _GetPP data1 data2 num i DIMZIN ) (defun _GetPP ( str / lst l post pre flag ) (setq lst (vl-remove 45 (vl-string->list str)) post (if (setq l (member 46 lst)) (- (length l) 1) 0) pre (if (setq l (member 46 (reverse lst))) (- (length l) 1) (length lst)) flag (minusp (atof str)) ) (list pre post flag) ) (setq DIMZIN (getvar 'DIMZIN)) (setvar 'DIMZIN 0) (setq data1 (_GetPP str) num (vl-string->list (rtos (f (atof str) n) 2 (cadr data1))) data2 (_GetPP (vl-list->string num)) num (vl-remove 45 num) ) (setvar 'DIMZIN DIMZIN) (if (< 0 (setq i (- (car data1) (car data2)))) (repeat i (setq num (cons 48 num))) ) (if (< 0 (setq i (- (cadr data1) (cadr data2)))) (repeat i (setq num (append num '(48)))) ) (if (caddr data2) (setq num (cons 45 num))) (vl-list->string num) ) ;------------------------------------------------------------------------- ; Sub Function ;------------------------------------------------------------------------- (defun HUE:start( lst ) (vla-startundomark (HUE:end nil)) (list lst (mapcar 'getvar lst)) ) ;------------------------------------------------------------------------- ; Sub Function ;------------------------------------------------------------------------- (defun HUE:end ( d / doc ) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (and (cadr d) (mapcar 'setvar (car d) (cadr d))) (if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-endundomark doc)) doc ) ;------------------------------------------------------------------------- ; Sub Function ;------------------------------------------------------------------------- (defun _divideStr ( str / data i j k pre post ) (setq data (HUE:DivideNum str) k (last (cadr data)) j 0 pre "" post "" ) (foreach s (car data) (cond ( (< j k) (setq pre (strcat pre s))) ( (> j k) (setq post(strcat post s))) ( (= j k) (setq i s)) ) (setq j (+ 1 j)) ) (list pre i post) ) ;------------------------------------------------------------------------- ; Error Function ;------------------------------------------------------------------------- (defun *error* (s) (if OOv (HUE:End OOv)) (princ s) ) ;----------------------------------------------------------------------------------- ; Main Function ;----------------------------------------------------------------------------------- (setq str (HUE:MemoVar '*StartStr121007 getstring "StartString " "100") i 1 OOv (HUE:Start '(DIMZIN)) ) (and (vl-string-search "," str) (setq str (HUE:StringSubst "." "," str) f t) ) (mapcar 'set '(pre num post) (_DivideStr str)) (setq tag "TEXT1" num (HUE:StringCal num - i) ) (setvar 'ERRNO 0) (setvar 'DIMZIN (while (= 0 (getvar 'ERRNO)) (and (setq o (ssget "_+.:E:S:L" '((0 . "INSERT") (66 . 1)))) ;(C:PUTA);------------------------------------------------------put locatiecode----------------------------------- (vl-some '(lambda ( att ) (if (= tag (vla-get-tagstring att)) (progn (setq num (HUE:StringCal num + i) str (strcat pre num post) ) (if f (setq str (HUE:StringSubst "," "." str))) (vla-put-textstring att str) ) ) ) (vlax-invoke (vlax-ename->vla-object (ssname o 0)) 'getattributes) ) ) ) (HUE:End OOv) (princ) )(vl-load-com) thank you in advance PmxCAD
  8. i will give it a try
  9. BIGAL, I got it together and it works too. (defun c:findtext (/ str sstxt) (setq str (getstring t "\nSpecify string to find: ") sstxt (ssget "_X" (list '(0 . "TEXT") (cons 1 str))) );setq (if (/= sstxt nil) (sssetfirst nil sstxt) (progn (alert (strcat str " not found")) (command "refclose" "D" "") );progn );if (princ) );defun Thanks
  10. Thanks 1958 & ronjonp, i think i wil go for the 1958 one. i`ve not tried yet, no Autocad at the moment. But is it also possible to at (progn to the alert part to close refedit (command "refclose" "s") after the alert.
  11. Hello, I found a lisp on Lee`s website to search for and select text. A nice short routine and works perfectly. Now my question is: can an alert be given "not found" if the text is not found in the drawing and how?. (defun c:findtext ( / str ) (if (/= "" (setq str (getstring t "\nSpecify string to find: "))) (sssetfirst nil (ssget "_X" (list '(0 . "TEXT") (cons 1 str) ) ) ) ) (princ) ) something like, (alert str " not found") thank you in advance PmxCAD
  12. That's it, works perfectly. Thanks rlx
  13. finally at once. Thank you guys for your input. Now find out why excel is closed when the routine is ready. Which part should I delete from first post (fixo)? ;(nth 0 (nth 0 lst)) ;(nth 1 (nth 0 lst)) ;(nth 2 (nth 0 lst)) ;(nth 3 (nth 0 lst)) ;example (alert (strcat (strcat " column 1 . . . " (nth 0 (nth 0 lst))) "\n" (strcat " column 2 . . . " (nth 1 (nth 0 lst))) "\n" (strcat " column 3 . . . " (nth 2 (nth 0 lst))) "\n" (strcat " column 4 . . . " (nth 3 (nth 0 lst))))) Pmxcad
  14. yes, like that. In brief. I want to use it for my work, but for security reasons I work from a network that is not connected with the outside world, so no internet access. So I can not give you examples only a description. We have drawings with buildings. We color the spaces and put a text into them. I created a lisp requesting to select a closed polyline (on xref). This is brought up with ncopy and used for accering (solid with transparency) then you have to select the space number (on xref) to insert a block. This is in short. What I want to make now is to skip a few steps with this lisp. We receive from the client an excel list with building number, room number, color of the accering etc. And I do not know if it is possible to search for space number (on xref) make a selection set of these and select the close-closed polyline (on xref) and bring it up. Now we have to look in the excel list for this data. After this another lisp will run. This looks at the size of the polyline and looks at its dimensions and then determines the size of the paper size that is needed (1:50). it creates a new drawing zoomed in (layout 1:50) on that space. We draw on room level. Do you have any questions? I used google translate for this long story, so there may be some weird things in it.
  15. now only values between quotation marks
×