+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Forum Newbie
    Using
    not specified
    Join Date
    May 2006
    Posts
    3

    Default HELP - ; error: bad argument type: lentityp nil??

    Registered forum members do not see this ad.

    It adds everything up alright, but I get that error when it finishes. Can anyone help?

    Code:
    (defun c:takeoff ()
      ;(setvar "cmdecho" 0)
    
      ;TRYING TO COUNT PIPE ON PIPE LAYERS HERE
      
    ;CREATE SELECTION SET OF ALL LINES ON WHICHEVER LAYER" (NEED TO CREATE A LIST OF LAYERS TO CYCLE THROUGH)
      (setq ss1 (ssget "X" '((0 . "line") (8 . "0"))))
      ;GETS THE NUMBER OF ITEMS IN THE SELECTION SET
      (setq ssmembers (sslength ss1))
      ;sets counter to zero
    (setq ct1 0)
      (setq totallenth 0)
     ;(repeat ssmembers
     (while ct1 ssmembers
     ;GETS THE FIRST ITEM FROM THE SELECTION SET  
      (setq ent1 (entget (ssname ss1 ct1)))
     ;FINDS THE X AND Y COORDINATES OF THE FIRST ITEM
      (setq pt1 (cdr (assoc 10 ent1)))
      (setq pt2 (cdr (assoc 11 ent1)))
      ;FINDS THE DISTANCE BETWEEN THOSE POINTS
      (setq lenth1 (distance pt1 pt2))
       ;sets up a variable to add the lengths into
      (setq totallenth (+ lenth1 totallenth))
       ;increases counter by one
      (setq ct1 (1+ ct1))
      )
      
    
    
    
    
      ) ;_ end of defun

  2. #2
    Forum Deity
    Using
    not specified
    Join Date
    Jul 2004
    Location
    Anchorage, Alaska
    Posts
    2,074

    Default

    Your loop has a hiccup, it keeps going until the counter exceeds the number of items in the set, then it error out. I think you need to change just 1 line;

    (while ct1 ssmembers

    to

    (while (< ct1 ssmembers)

  3. #3
    Senior Member kpblc's Avatar
    Using
    AutoCAD 2005
    Join Date
    May 2006
    Location
    Russia, St-Petersburg
    Posts
    317

    Default

    Code:
    &#40;defun c&#58;takeoff2 &#40;/ adoc selset res&#41;
      &#40;vl-load-com&#41;
      &#40;setq	adoc &#40;vla-get-activedocument &#40;vlax-get-acad-object&#41;&#41;
    	res  0.0
    	&#41; ;_ end of setq
      &#40;vla-startundomark adoc&#41;
      &#40;if &#40;setq selset &#40;ssget "_X" '&#40;&#40;0 . "LINE,LWPOLYLINE"&#41; &#40;8 . "0"&#41;&#41;&#41;&#41;
        &#40;foreach item &#40;vl-remove-if 'listp &#40;mapcar 'cadr &#40;ssnamex selset&#41;&#41;&#41;
          &#40;setq res &#40;+ res &#40;vla-get-length &#40;vlax-ename->vla-object item&#41;&#41;&#41;&#41;
          &#41; ;_ end of foreach
        &#41; ;_ end of if
      &#40;vla-endundomark adoc&#41;
      &#40;princ &#40;strcat "\nSum length &#58; " &#40;rtos res 2&#41;&#41;&#41;
      &#40;princ&#41;
      &#41; ;_ end of defun
    All I say is only my opinion.

  4. #4
    Forum Newbie
    Using
    not specified
    Join Date
    May 2006
    Posts
    3

    Default

    Thanks guys -

    kpblc - you just jumped way over my head. I've never quite figured out how to use any of that vl- vla- stuff.

    Carl - I think I've tried that, but I'll go back and look at it again.

  5. #5
    Senior Member kpblc's Avatar
    Using
    AutoCAD 2005
    Join Date
    May 2006
    Location
    Russia, St-Petersburg
    Posts
    317

    Default

    It's simple very much
    And I don't know another simple way to get length of lightweightpolyline or 3d-polyline - only (vla-get-length).
    All I say is only my opinion.

  6. #6
    Forum Newbie
    Using
    not specified
    Join Date
    May 2006
    Posts
    3

    Default

    It is time for me to learn something new.

    Can you use the same thing to add arc lengths too? Those are the three I usually have, lines, polylines and arcs.

  7. #7
    Senior Member kpblc's Avatar
    Using
    AutoCAD 2005
    Join Date
    May 2006
    Location
    Russia, St-Petersburg
    Posts
    317

    Default

    Registered forum members do not see this ad.

    Why not?
    Code:
    &#40;defun c&#58;takeoff3 &#40;/ adoc selset res&#41;
      &#40;vl-load-com&#41;
      &#40;setq	adoc &#40;vla-get-activedocument &#40;vlax-get-acad-object&#41;&#41;
    	res  0.0
    	&#41; ;_ end of setq
      &#40;vla-startundomark adoc&#41;
      &#40;if &#40;setq selset &#40;ssget "_X" '&#40;&#40;0 . "LINE,LWPOLYLINE,ARC"&#41; &#40;8 . "0"&#41;&#41;&#41;&#41;
        &#40;foreach item &#40;vl-remove-if 'listp &#40;mapcar 'cadr &#40;ssnamex selset&#41;&#41;&#41;
          &#40;cond
    	&#40;&#40;= &#40;cdr &#40;assoc 0 &#40;entget item&#41;&#41;&#41; "ARC"&#41;
    	 &#40;setq res &#40;+ res &#40;vla-get-arclength &#40;vlax-ename->vla-object item&#41;&#41;&#41;&#41;
    	 &#41;
    	&#40;t
    	 &#40;setq res &#40;+ res &#40;vla-get-length &#40;vlax-ename->vla-object item&#41;&#41;&#41;&#41;
    	 &#41;
    	&#41; ;_ end of cond
          &#41; ;_ end of foreach
        &#41; ;_ end of if
      &#40;vla-endundomark adoc&#41;
      &#40;princ &#40;strcat "\nSum length &#58; " &#40;rtos res 2&#41;&#41;&#41;
      &#40;princ&#41;
      &#41; ;_ end of defun
    All I say is only my opinion.

Bookmarks

Posting Permissions

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