Results 1 to 2 of 2

Thread: Autocad Error “error: bad arguement type: lselsetp nil” when selecting polyline

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2012-09
    Posts
    1
    Login to Give a bone
    0

    Default Autocad Error “error: bad arguement type: lselsetp nil” when selecting polyline

    Hey Team,

    I am currently attempting to run a polyline between two blocks (first_block, second_block) that runs along another polyline, at the end of the action an insert function is called that populates an annotation block (cable_name_tag) using data taken from the start and end block.

    This polyline will need to transect other blocks and as stated will primarily run in paralell with an underlying polyline (cable_ducting) and it will be the user who will need to select an appropriate part of the polyline to drop the annotation, as space is sometimes limited.

    I have noted that if I comment out the second_block and provide a harcoded value the ssget function works without issue, so I am reasonably sure the issue is with either with the syntax or the handling of the first_block and second_block and data in that code.

    Code example below:

    Code:
    (defun c:cable ()
    	(vl-load-com)
    	(setvar "clayer" "cable layer")
    	(setvar "celtype" "bylayer")
    	(setvar "osmode" 515 )
    	(command "_.pline"
    		(getpoint)
    	)
    	(while 
    		(> 
    			(getvar ' cmdactive) 0 
    		)	  
    		(command pause)	     
    	    (princ "\npress enter to finish:")	     
    	)
     	(setq elst 
    		(entsel "\nselect cable segment: ")
    	)
        (setq ename 
    		(car elst)
    	)
     	(setq pt 
    		(cadr elst)
    	)
        (setq annopt pt)
     	(setq pt 
    		(vlax-curve-getclosestpointto ename pt)
    	)
     	(setq param 
    		(vlax-curve-getparamatpoint ename pt)
    	)
     	(setq preparam 
    		(fix param)
    	)
     	(setq postparam 
    		(1+ preparam)
    	)
     	(list
     		(setq pt1
    			(vlax-curve-getpointatparam ename preparam)
    		)
     		(setq pt2
    			(vlax-curve-getpointatparam ename postparam)
    		)
     	)
    	(setq cable 
    		(entlast)
    	)
    	(setq cable_start
    		(vlax-curve-getstartparam cable)
    	)
    	(setq cable_start_point
    		(vlax-curve-getstartpoint cable)
    	)
    	(setq cable_end_point
    		(vlax-curve-getendpoint cable)
    	)
    	(setq cable_end 
    		(angtos 
    			(angle '
    				(0 0 )
    				(vlax-curve-getfirstderiv cable 0.0)
    			)
    		)
    	)
    	(setq first_block
    		(ssget "_c" cable_start_point cable_end_point
    			(list
    				(cons 0 "insert")
    				(cons 2 "first_block")
    			)
    		)
    	)
      	(setq second_block
    		(ssget "_c" cable_start_point cable_end_point 
    			(list
    				(cons 0 "insert")
    				(cons 2 "second_block")
    			)
    		)
    	)
    	(setq end_cable 
    		(ssname second_block 0)
    	)	
        (setq start_cable 
    		(ssname first_block 0)
    	)
        (setq $end_cable
    		(vla-get-textstring
    			(cadr 
    				(vlax-safearray->list
    					(variant-value
    						(vla-getattributes
    							(vlax-ename->vla-object end_cable)
    						)
    					)
    				)
    			)
    		)
    	)
    	(setq $start_cable
    		(vla-get-textstring
    			(cadr
    				(vlax-safearray->list
    					(variant-value
    						(vla-getattributes
    							(vlax-ename->vla-object start_cable)
    						)
    					)
    				)
    			)
    		)
    	)
    	(setq cable_name
    		(vlax-curve-getendparam cable)
    	)
    	(command 
    		; insert cable param
    		"-insert" 
    		"cable_name_tag"  
    		annopt 
    		"1" 
    		"1" 
    		cable_angle 
    		cable_name 
    		$start_cable
    		$end_cable
    		"144"
    		cable_length
    	)
    ); end of duct function
    I am relatively new to vLisp and such, but am very keen to get my teeth into it - and excited to see the results of joining the AUGI forums.

    Thanks for your time
    Attached Files Attached Files
    Last edited by Opie; 2012-09-21 at 09:11 PM. Reason: [code] tags added

  2. #2
    All AUGI, all the time marko_ribar's Avatar
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    556
    Login to Give a bone
    0

    Default Re: Autocad Error “error: bad arguement type: lselsetp nil” when selecting polyline

    You have to draw pline from block named "first block" and finish pline with point at block named "second block" - these blocks have to have attributes witch will be used later in insert command - so you have to have also block named "cable_name_tag" stored in memory and it also has to have attributes... Still I've modified your code with by my opinion adequate variable values - check it and compare with your code... Next time please use code tags :
    [code] Your code [/code] and before posting format it in VLIDE without tab spaces (uncheck option tabs in Environment options, and you may also check option to check variables when checking code in General options) - after do save changes to vlide...

    Code:
    (defun c:cable (/              $END_CABLE     $START_CABLE
                    ANNOPT         CABLE          CABLE_ANGLE
                    CABLE_END      CABLE_END_POINT
                    CABLE_LENGTH   CABLE_NAME     CABLE_START
                    CABLE_START_POINT             ELST
                    END_CABLE      FIRST_BLOCK    PARAM
                    POSTPARAM      PREPARAM       PT
                    PT1            PT2            SECOND_BLOCK
                    START_CABLE
                   )
      (vl-load-com)
      (if (tblsearch "LAYER" "cable layer")
        (setvar "clayer" "cable layer")
      )
      (setvar "celtype" "bylayer")
      (setvar "osmode" 515)
      (command "_.pline")
      (while
        (>
          (getvar 'cmdactive)
          0
        )
         (command pause)
         (princ "\npress enter to finish:")
      )
      (setq elst
             (entsel "\nselect cable segment: ")
      )
      (setq cable
             (car elst)
      )
      (setq pt
             (cadr elst)
      )
      (setq pt
             (vlax-curve-getclosestpointto cable pt)
      )
      (setq annopt pt)
      (setq param
             (vlax-curve-getparamatpoint cable pt)
      )
      (setq preparam
             (fix param)
      )
      (setq postparam
             (1+ preparam)
      )
      (setq pt1
             (vlax-curve-getpointatparam cable preparam)
      )
      (setq pt2
             (vlax-curve-getpointatparam cable postparam)
      )
      (setq cable_angle
             (angtos
               (angle pt1 pt2)
             )
      )
      (setq cable_start
             (vlax-curve-getstartparam cable)
      )
      (setq cable_end
             (vlax-curve-getendparam cable)
      )
      (setq cable_start_point
             (vlax-curve-getstartpoint cable)
      )
      (setq cable_end_point
             (vlax-curve-getendpoint cable)
      )
      (setq first_block
             (ssget "_c"
                    cable_start_point
                    cable_end_point
                    (list
                      (cons 0 "insert")
                      (cons 2 "first_block")
                    )
             )
      )
      (setq second_block
             (ssget "_c"
                    cable_start_point
                    cable_end_point
                    (list
                      (cons 0 "insert")
                      (cons 2 "second_block")
                    )
             )
      )
      (setq end_cable
             (ssname second_block 0)
      )
      (setq start_cable
             (ssname first_block 0)
      )
      (setq $end_cable
             (vla-get-textstring
               (cadr
                 (vlax-safearray->list
                   (variant-value
                     (vla-getattributes
                       (vlax-ename->vla-object end_cable)
                     )
                   )
                 )
               )
             )
      )
      (setq $start_cable
             (vla-get-textstring
               (cadr
                 (vlax-safearray->list
                   (variant-value
                     (vla-getattributes
                       (vlax-ename->vla-object start_cable)
                     )
                   )
                 )
               )
             )
      )
      (setq cable_name
             (vla-get-handle (vlax-ename->vla-object cable))
      )
      (setq cable_length
             (vla-get-length (vlax-ename->vla-object cable))
      )
      (command
        "-insert"      "cable_name_tag"              annopt
        "1"            "1"            cable_angle    cable_name
        $start_cable   $end_cable     "144"          cable_length
       )
    )
    M.R.
    Last edited by marko_ribar; 2012-09-20 at 09:53 AM.
    Marko Ribar, d.i.a. (graduated engineer of architecture)

    M.R. on Youtube


Similar Threads

  1. Replies: 1
    Last Post: 2012-11-12, 11:12 PM
  2. Replies: 4
    Last Post: 2009-05-22, 05:21 AM
  3. Error: bad argument type: lselsetp nil
    By stusic in forum AutoLISP
    Replies: 1
    Last Post: 2008-02-20, 10:02 PM
  4. Replies: 8
    Last Post: 2007-01-03, 02:32 PM
  5. Replies: 3
    Last Post: 2006-12-11, 08:31 PM

Tags for this Thread

Posting Permissions

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