Results 1 to 4 of 4

Thread: Point Layer Counter

  1. #1
    Active Member
    Join Date
    2005-12
    Posts
    90
    Login to Give a bone
    0

    Default Point Layer Counter

    The purpose of this programs is to make a list of information embedded in points - x coordinate, y coordinate, a database key, the layer of the point, and a counter of the points on the layer.

    The most recent error is:
    ; error: bad argument type: listp #<SUBR @0752b514 ENTLAST>

    Any help is appreciated.
    Thanks,
    TC
    Code:
    (defun c:ptlayerct (/ alldots fn curlay alldotsct layerlist layeritem layerstring ctdel)
    (setq fn (open "ptlayerct.txt" "a"))
    ;(setq alldotsct 0)
    (setq alldots (ssget "X" '((0 . "point"))))
    (repeat (sslength alldots);a
    (setq cur_lay (cdr (assoc 8 entlast))))
    (setq ct 0)
    ;(setq alldotsct (1+ alldotsct))
    (setq layerlist (ssget "X" '((8 . (curlay))))); this is where a problem is occuring
    (repeat (sslength layerlist) ;b
    (setq layeritem (entget (ssname layerlist ct)))
    (setq ct (1+ ct))
    (setq layerstring (strcat "0" "t" (itoa (cadr (cdr (assoc 10 layeritem)))) "t" curlay "t" ct))
    (write-line layerstring fn)
      ); b ends
    (setq ctdel 0)
    (repeat (sslength layerlist) ;c
    (setq layeritem (entget (ssname layerlist ctdel)))
    (setq ctdel (1+ ctdel))
    (entdel layeritem)) ; c ends
      (CLOSE fn)
      )
    Last edited by Opie; 2008-02-15 at 03:45 PM. Reason: fixed code tag

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: Point Layer Counter

    Quote Originally Posted by trconnet View Post
    The most recent error is:
    ; error: bad argument type: listp #<SUBR @0752b514 ENTLAST>
    Code:
    (defun c:ptlayerct (/ alldots fn curlay alldotsct layerlist layeritem layerstring ctdel)
    (setq fn (open "ptlayerct.txt" "a"))
    ;(setq alldotsct 0)
    (setq alldots (ssget "X" '((0 . "point"))))
    (repeat (sslength alldots);a
    (setq cur_lay (cdr (assoc 8 entlast))))
    (setq ct 0)
    ;(setq alldotsct (1+ alldotsct))
    (setq layerlist (ssget "X" '((8 . (curlay))))); this is where a problem is occuring
    (repeat (sslength layerlist) ;b
    (setq layeritem (entget (ssname layerlist ct)))
    (setq ct (1+ ct))
    (setq layerstring (strcat "0" "t" (itoa (cadr (cdr (assoc 10 layeritem)))) "t" curlay "t" ct))
    (write-line layerstring fn)
      ); b ends
    (setq ctdel 0)
    (repeat (sslength layerlist) ;c
    (setq layeritem (entget (ssname layerlist ctdel)))
    (setq ctdel (1+ ctdel))
    (entdel layeritem)) ; c ends
      (CLOSE fn)
      )
    ENTLAST does not return a list, it returns an entity name. You will need to ENTGET the list from the entity name before you can extract the layer name of the last entity.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    277
    Login to Give a bone
    0

    Default Re: Point Layer Counter

    Hi
    Code:
    (defun c:ptlayerct (/ alldots cnt ct cur_lay f fol layerlist
    		    layerstring li sse sse_cur_lay ssl
    		    ssl_layerlist ssn ssn_cur_lay)
      (if
        (setq alldots (ssget "X" '((0 . "point"))))
        (progn
          (setq ssl (sslength alldots))
          (setq cnt 0)
          (repeat
    	ssl
    	(setq ssn (ssname alldots cnt))
    	(setq sse (entget ssn))
    	(setq cur_lay (cdr (assoc 8 sse)))
    	(setq layerlist (ssget "X" (list (cons 8 cur_lay))))
    	(setq ssl_layerlist (sslength layerlist))
    	(setq ct 0)
    	(repeat
    	  ssl_layerlist
    	  (setq ssn_cur_lay (ssname layerlist ct))
    	  (setq sse_cur_lay (entget ssn_cur_lay))
    	  (setq li (cadr (cdr (assoc 10 sse_cur_lay))))
    	  (setq layerstring (strcat "0" "t" (rtos li) "t" cur_lay "t" (itoa ct)))
    	  (setq fol "D:/YBI/Temp/ptlayerct.txt")
    	  (setq f (open fol "w"))
    	  (write-line layerstring f)
    	  (close f)
    	  (command "_erase" ssn_cur_lay "")
    	  (setq ct (1+ ct))
    	  ) ; repeat
    	(setq cnt (1+ cnt))
    	)   ; repeat
          )     ; progn
        (alert "\nThere is not object POINT")
        )       ; if
      (princ)
      )         ; defun
    Very sorry this still problem in ssget function, look at result test
    Command: ptlayerct
    ; error: bad SSGET list value

  4. #4
    Active Member
    Join Date
    2005-12
    Posts
    90
    Login to Give a bone
    0

    Default Re: Point Layer Counter

    I am trying something different. The current problem is the output is blank. The acad_strlsort seems to be failing. I probably have a bad counter or something. Thank you for any help,
    TC
    Code:
    (defun C:HYDLISTPT (/ ALLDOTS ALLDOTSCT DL DLIST HYDIDLIST1 HYDIDLIST2 CT2 CTDLIST KEYCT FN FINAL HCT)
    (setq ALLDOTSCT 0) (SETQ FN (OPEN "PTLYAERCT.TXT" "A"))
    (setq ALLDOTS (ssget "X" '((0 . "POINT"))))
    (REPEAT ; THIS REPEAT MAKE A LIST OF LAYERS AND Y COORDINATES
      (SSLENGTH ALLDOTS)
      (SETQ DL NIL)
    (setq DL
           (list (CONS "HYD_ID" (ASSOC 8 (ENTGET (SSNAME ALLDOTS ALLDOTSCT))) )))
          (SETQ DL (APPEND (LIST (CONS "HYD_KEY" (ITOA (FIX (CADR (CDR (ASSOC 10 (ENTGET (SSNAME ALLDOTS ALLDOTSCT)) ))))) )) DL))
          	(SETQ DLIST (LIST DL DLIST)))
    (repeat ;THIS REPEAT CREATES THE LIST OF LAYERS
      (sslength ALLDOTS)
    	(setq HYDIDLIST1  (APPEND (LIST (CADR (ASSOC 8 (ENTGET (SSNAME ALLDOTS ALLDOTSCT)))) HYDIDLIST1))))
    	(SETQ HYDIDLIST1 (ACAD_STRLSORT HYDIDLIST1)) (SETQ HCT 0); THIS SORTS THE LAYERS IN SOME ORDER
    (WHILE ;THIS FINDS THE LAST OCCURANCES OF EACH LAYER AND MAKE A LIST
      	(IF (= (NTH HCT HYDIDLIST1) (NTH (1+ HCT) HYDIDLIST1)) (SETQ HCT (1+ HCT))
    	(PROGN
    		(SETQ HYDIDLIST2 (APPEND (LIST (NTH HCT HYDIDLIST1)) HYDIDLIST2)) (SETQ HCT (1+ HCT))
    	);END PROGN
    	  );END IF
      		);END WHILE
    (SETQ CT2 0 CTDLIST 0 KEYCT 0)
    (WHILE (
    	(WHILE (= (NTH CT2 HYDIDLIST2) (NTH CTDLIST (CADR (CDR (ASSOC "HYD_ID" DLIST)))))
    	(SETQ FINAL (LIST (CADR (CDR (ASSOC "HYD_ID" DLIST))) (CADR (CDR (ASSOC "HYD_KEY" DLIST))) (itoa (1+ KEYCT)))) (SETQ CTDLIST (1+ CTDLIST))
    	); END 2ND WHILE
    	) (SETQ CT2 (1+ CT2) CTDLIST 0 KEYCT 0)(write-line FINAL FN)
    	)
    (CLOSE FN);END 1ST WHILE
      (PRINC))
    Last edited by trconnet; 2008-02-21 at 03:59 PM. Reason: squashing bugs

Similar Threads

  1. CV104-1P: One Point, Two Point, Red Point, Blue Point
    By Autodesk University in forum Civil Infrastructure
    Replies: 0
    Last Post: 2013-05-05, 03:17 AM
  2. CV12-4: One Point, Two Point, Red Point, Blue Point
    By Autodesk University in forum Civil Infrastructure
    Replies: 0
    Last Post: 2013-04-17, 04:50 AM
  3. Replies: 12
    Last Post: 2010-09-03, 06:21 PM
  4. Obtain layer name from insertion point
    By cadconcepts in forum AutoLISP
    Replies: 3
    Last Post: 2010-01-22, 04:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •