Author Topic: [Newb Help] Filter Objects using dxf code value  (Read 6331 times)

0 Members and 1 Guest are viewing this topic.

JCTER

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #15 on: December 14, 2009, 10:39:47 AM »
NECRO BUMP!

Ok, I'm confused.  Somehow I seem to have broken my little utility that y'all helped me to hack together.

Code: [Select]
;;;--- GET SELECTION SET OF EXISTING SURVEY POINTS AND ASSIGN IT TO SOMETHING TO BE CALLED
(setq ss(ssget "_X" (list (cons 0 "ACAD_PROXY_ENTITY"))))

;;;--- BEGIN WHILE LOOP TO RUN TYPICAL ACTIONS
(while (< 0 (sslength ss))
  (command "explode" (ssname ss 0))
  (surveycleaner)
  (ssdel (ssname ss 0) ss)
)
(princ)
)

Given the above code, and verifying that I -do- indeed have a number of ACAD_PROXY_ENTITY's in my drawing, when the above code gets to the "EXPLODE" command (for the first time), it returns an error:
Quote
Command: ; error: bad argument type: lselsetp nil
Which I understand to mean that my selection set is 'nil' when I try to run a command on it.

I don't understand why that is though.  In my limited understanding, I go through the code and see no reason why I don't have selections made.

I've attached the lisp file and the drawing in their entirety, if it helps.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: [Newb Help] Filter Objects using dxf code value
« Reply #16 on: December 14, 2009, 10:46:50 AM »
Looking at the first two lines I'd localize some variables...see if that helps:

Code: [Select]
(defun c:surveycleaner
       (/ desc desel eleel elev newdesc newelev newnumber node nodel number numel ss)
  (defun c:pointfix (/ ss)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

JCTER

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #17 on: December 14, 2009, 10:49:50 AM »
Looking at the first two lines I'd localize some variables...see if that helps:

Code: [Select]
(defun c:surveycleaner
       (/ desc desel eleel elev newdesc newelev newnumber node nodel number numel ss)
  (defun c:pointfix (/ ss)

A suggestion I'd thought of but was not sure of the ramifications of doing.  I've done so (still get the error unfortunately.

I'm trying to use the VLIDE to step through it now, but takes me a bit to feel my way through using the thing.

JCTER

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #18 on: December 14, 2009, 10:52:22 AM »
Yea, the "ERROR TRACE" results don't tell me much I didn't know already... my selection set is empty before it even tries running the 'while' loop

I can only assume there is a problem here:
Code: [Select]
(setq ss(ssget "_X" (list (cons 0 "ACAD_PROXY_ENTITY"))))
But for the life of me, I'm just not seeing it.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: [Newb Help] Filter Objects using dxf code value
« Reply #19 on: December 14, 2009, 11:00:57 AM »
Try something like this:

Code: [Select]
(setq n -1)
(if (setq ss (ssget "_X" (list (cons 0 "ACAD_PROXY_ENTITY"))))
;;;--- BEGIN WHILE LOOP TO RUN TYPICAL ACTIONS
  (while (setq e (ssname ss (setq n (1+ n))))
    (command "_.explode" e)
    (surveycleaner)
  )
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

JCTER

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #20 on: December 14, 2009, 11:07:12 AM »
Just tried something different... I entered the selection set part independently, to see what'd happen, and got:

Code: [Select]
Command: (setq MyFilter(list (cons 0 "ACAD_PROXY_ENTITY")))
((0 . "ACAD_PROXY_ENTITY"))

Command: (setq ss(ssget "X" MyFilter))
<Selection set: 330>

Command: (sslength ss)
557

So apparently that code works fine... but when ran in the entirety of my LISP routine, it doesn't... so now I'm very confused.

Trying your way now, ronjonp.
*EDIT*
Quote
Command: ; error: bad argument type: lselsetp nil

No Dice :(

JCTER

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #21 on: December 14, 2009, 11:18:25 AM »
I simply don't understand where this could be failing.

If I enter the selection bit at the command prompt:

Quote
Command: (setq ss (ssget "_X" (list (cons 0 "ACAD_PROXY_ENTITY"))))
<Selection set: 357>

To see if it works... and then ask the length of the selection set:
Quote
Command: (sslength ss)
557

It shows 557 entities in the selection set.

Yet when I run the entirety of the routine, it comes up with an empty selection set?  Very strange.  I look at what is going on leading up to the point where it runs the SSGET but nothing seems to happen that would interfere with it... unless I am totally in the dark here.  (possible)

JCTER

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #22 on: December 14, 2009, 11:19:10 AM »
I've tried running this routine in Autocad 2010 and 2009 and am going to try 2008 :\

*edit* heh, oops.  Looks like I don't have 08 on here anymore, oh well.  I know it worked in 09 before, though :\  I -must- be overlooking something simple.
« Last Edit: December 14, 2009, 11:26:54 AM by James Cannon »

JCTER

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #23 on: December 14, 2009, 11:37:59 AM »
Ok, got the selection working, now it gives me:
Quote
Command: _.explode
Select object:
Command: ; error: no function definition: SURVEYCLEANER

This is an awesome Monday.

So, when running the POINTFIX routine, how can there be no definition for SURVEYCLEANER if SURVEYCLEANER is defined before POINTFIX?
Code: [Select]
(defun c:surveycleaner
       (/ desc desel eleel elev newdesc newelev newnumber node nodel number numel ss)
  (defun c:pointfix (/ ss)

ronjonp

  • Needs a day job
  • Posts: 7529
Re: [Newb Help] Filter Objects using dxf code value
« Reply #24 on: December 14, 2009, 11:43:12 AM »
It's because you are calling (surveycleaner) and the routine is defined as c:surveycleaner.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: [Newb Help] Filter Objects using dxf code value
« Reply #25 on: December 14, 2009, 11:47:03 AM »
James, did you look at my code as posted above?  (think that was actually my very first post at theSwamp..)

JCTER

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #26 on: December 14, 2009, 11:56:18 AM »
James, did you look at my code as posted above?  (think that was actually my very first post at theSwamp..)

I did, and I tried to apply it to my idea... but I ran into a couple errors when integrating it with the 'pointfix' routine and ... I really had -no- idea what was going on in your code, because I don't understand a lot of what you did, and it sailed well over my head, so I was unable to troubleshoot it :\

Now I got my original code to work after removing the "c:" from the surveycleaner call (I understand what I did now, and how that affects how I call the routine, now) but now my
Quote
; error: bad argument type: lselsetp nil
is back... so now I have to figure out what the heck changed, there.

JCTER

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #27 on: December 14, 2009, 12:13:04 PM »
HAHAHAHA

I found it!!!

The problem with the selection set WASN'T when it was getting all objects... it was:

Quote
(setq number(ssget "_X" '((62 . 4)(8 . "PT 12.11.09"))))      ;;;---selection set of objects color 'cyan' layer PT

It was in the Surveycleaner routine, AFTER the explode!!  I was mislead by the error output and looking in the wrong place, all along.  The layer name is "PTS 12.11.09"


Boy I feel dumb, now :(

Thank you so much again, guys, for holding my hand while I figure out my stupid mistakes  :-D  Even though this problem was a STUPID TYPO, I still came away from this session with a few lessons.