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

0 Members and 1 Guest are viewing this topic.

James Cannon

  • Guest
[Newb Help] Filter Objects using dxf code value
« on: May 01, 2009, 03:17:25 PM »
Code: [Select]
(setq ss(ssget "_X" (list (cons 0 "ACAD_PROXY_ENTITY"))))
I had to trouble shoot that line a few times to get it to work, it always gave be "Bad SSGET list" until I made it as you see above.  Now I get:


Quote
Command: ; error: bad argument type: lselsetp nil

However, I have no idea where to look to figure out what's wrong :(

Here is the entire .lsp, for context.

I define the function "SurveyCleaner" first, then define a function, "pointfix" that creates a selection set of all AUTOCAD_PROXY_ENTITY 's in the drawing, and for each of them, runs "SurveyCleaner" but I assume my programming logic fails somewhere, and something is not doing what I think it's going to do.... I just have no idea what :(

Code: [Select]
(defun SurveyCleaner()

;;;--- ACTIONS TO BE EXECUTED FOR EACH ITEM SELECTED IN THE 'PointFix' routine below
(setq number(ssget "_X" '((62 . 4)(8 . "PT")))) ;;;---selection set of objects color 'cyan' layer PT
(setq elev(ssget "_X" '((62 . 7)(8 . "PT")))) ;;;---selection set of objects color 'white' layer PT
(setq desc(ssget "_X" '((62 . 3)(8 . "PT")))) ;;;---selection set of objects color 'green' layer PT
(setq node(ssget "_X" '((62 . 256)(8 . "PT")))) ;;;---selection set of objects color 'ByLayer' layer PT

(setq numEL (entget number))
(setq eleEL (entget elev))
(setq desEL (entget desc))
(setq nodEL (entget node))

;;;--- CREATE 'NEWNUMBER'
(setq newnumber(list
(cons 0 "MTEXT")
(cons 8 "SRVY-POINT-No")
(cons 100 "AcDbMText")
(cons 62 "256")
(cons 7 "SurveyData")
(cons 40 12.0)
(cons 41 1.0)
(cons 42 1.0)
(cons 50 0.0)
(cons 73 1.0)
(cons 10 (cdr (assoc 10 numEL)))
(cons 1 (cdr (assoc 1 numEL)))
)
)
(entmake newnumber)


;;;--- CREATE 'NEWELEV'
(setq newelev(list
(cons 0 "MTEXT")
(cons 8 "SRVY-POINT-ELEV")
(cons 100 "AcDbMText")
(cons 62 "256")
(cons 7 "SurveyData")
(cons 40 12.0)
(cons 41 1.0)
(cons 42 1.0)
(cons 50 0.0)
(cons 73 1.0)
(cons 10 (cdr (assoc 10 eleEL)))
(cons 1 (cdr (assoc 1 eleEL)))
)
)
(entmake newelev)




;;;--- CREATE 'NEWDESC'
(setq newdesc(list
(cons 0 "MTEXT")
(cons 8 "SRVY-POINT-DESC")
(cons 100 "AcDbMText")
(cons 62 "256")
(cons 7 "SurveyData")
(cons 40 12.0)
(cons 41 1.0)
(cons 42 1.0)
(cons 50 0.0)
(cons 73 1.0)
(cons 10 (cdr (assoc 10 desEL)))
(cons 1 (cdr (assoc 1 desEL)))
)
)
(entmake newdesc)
;;;--- CREATE 'NEWNODE'
(setq newnode(list
(cons 0 "MTEXT")
(cons 8 "SRVY-POINT-No")
(cons 100 "AcDbMText")
(cons 62 "256")
(cons 7 "SurveyData")
(cons 40 12.0)
(cons 41 1.0)
(cons 42 1.0)
(cons 50 0.0)
(cons 73 1.0)
(cons 10 (cdr (assoc 10 nodEL)))
(cons 1 (cdr (assoc 1 nodEL)))
)
)
(entmake newnode)
(princ)
)

;;;------------------------------------
;;;------------------------------------
;;;------------------------------------

(defun C:pointfix()
;;;--- CREATE NEW LAYERS REQUIRED
(command "-style" "SurveyData" "RomanS" 0 1 0 "No" "No" "No")
(command "-layer" "m" "SRVY-POINT-No" "C" 7 "" "")
(command "-layer" "m" "SRVY-POINT-ELEV" "C" 32 "" "")
(command "-layer" "m" "SRVY-POINT-DESC" "C" 52 "" "")
(command "-layer" "m" "SRVY-POINT-NODE" "C" 62 "" "")
(command "-layer" "m" "SRVY-TEMP-PT" "C" 3 "" "")

;;;--- 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 (< (sslength eset)) SurveyCleaner)
(princ)
)

James Cannon

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #1 on: May 01, 2009, 03:25:41 PM »
I'm mainly hoping to get an educated pair of eyes on what I'm doing, hoping some guiding light could be shed on my work :\

To explain what I'm trying to do:

I get a survey file that has point data as proxy entities, and I want to create a survey that we can work better with, turn off layers, etc.  As it is, all objects are on one layer, different colors, and all around a PITA to work with if we want to view it differently.

My boss decided the easiest thing to do in the whole situation was task me with creating a routine to take the surveyors points in CAD, and modify them. 

The surveyor -does- send us an .asc file with raw point data, but I only just now realized this, and I'm already a good ways invested in the route I've chosen, so I hammer on.

I wish to do this to each entity:

explode it, select the 'cyan' entity which is an mtext object containing the point #, and create a new piece of mtext with insertion point and content matched to the old, and all other properties (layer, color, textstyle, etc) as I see fit.

mimic that for green entity, and white entity.

Then I wish to repeat that process for each and every AUTOCAD_PROXY_ENTITY in the drawing.

Then, I won't be at 100% done, but will be mostly there.


mkweaver

  • Bull Frog
  • Posts: 352
Re: [Newb Help] Filter Objects using dxf code value
« Reply #2 on: May 01, 2009, 04:11:40 PM »
James,
First off, in this section:
Code: [Select]
(setq numEL (entget number))
(setq eleEL (entget elev))
(setq desEL (entget desc))
(setq nodEL (entget node))
You are calling entget on a selection set, when it expects an entity name.  Try this instead:
Code: [Select]
(setq numEL (entget (ssname number 0)))
(setq eleEL (entget (ssname elev 0)))
(setq desEL (entget (ssname desc 0)))
(setq nodEL (entget (ssname node 0)))

However, what I've given, above, does no checking in case there was nothing selected.

James Cannon

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #3 on: May 01, 2009, 04:14:12 PM »
I see.  I am still very rough and unstable with understanding exactly what some of these things expect.

I have updated my routine with those changes.  Thank you for the input!

I really don't have -any- error trapping or 'checks' ... which may be why this is so hard for me as yet, but i was afraid, in my incompetence, that I would introduce further errors, if I error trapped improperly, and that it would confuse me further, and end up doing more harm than good. 

mkweaver

  • Bull Frog
  • Posts: 352
Re: [Newb Help] Filter Objects using dxf code value
« Reply #4 on: May 01, 2009, 04:25:27 PM »
I see.  I am still very rough and unstable with understanding exactly what some of these things expect.

I have updated my routine with those changes.  Thank you for the input!

I really don't have -any- error trapping or 'checks' ... which may be why this is so hard for me as yet, but i was afraid, in my incompetence, that I would introduce further errors, if I error trapped improperly, and that it would confuse me further, and end up doing more harm than good. 

I understand your concerns about error checking introducing problems, though more often it simply hides them.  If you do your development in the visual lisp IDE and use breakpoints and step through your code with a watch window, you can typically tell where your errors are and, with a bit of practice, learn to decipher the error messages.

Keep the questions coming.

Mike

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: [Newb Help] Filter Objects using dxf code value
« Reply #5 on: May 01, 2009, 04:32:26 PM »
The while loop isn't doing anything ....that is it wouldn't if you got past the error of "lselsetp nil" which is occurring due to this:
(while (< (sslength eset)) ... you defined your Selection Set to be ss, not eset

Once that is fixed, you still need to get the (while) to do something...more like so:
Code: [Select]
(while (< 0 (sslength ss))
  (command "explode" (ssname ss 0))
  (surveycleaner)
  (ssdel (ssname ss 0) ss)
)

James Cannon

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #6 on: May 01, 2009, 04:53:49 PM »
grr.

I see what I did there.

I see what you did, and that makes much sense, JeffM.  Thank you.  Most of my stuff is "shootin' from the hip" unfortunately.

I see.  I am still very rough and unstable with understanding exactly what some of these things expect.

I have updated my routine with those changes.  Thank you for the input!

I really don't have -any- error trapping or 'checks' ... which may be why this is so hard for me as yet, but i was afraid, in my incompetence, that I would introduce further errors, if I error trapped improperly, and that it would confuse me further, and end up doing more harm than good. 

I understand your concerns about error checking introducing problems, though more often it simply hides them.  If you do your development in the visual lisp IDE and use breakpoints and step through your code with a watch window, you can typically tell where your errors are and, with a bit of practice, learn to decipher the error messages.

Keep the questions coming.

Mike

Shoot, I hadn't even thought of that.  I should have... I was used to stepping through VBA code that way, but I have been working in notepadd++ for the LISP heh... I shall swap over.

James Cannon

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #7 on: May 01, 2009, 05:09:14 PM »
Ok, so I'm having trouble with:
   
Code: [Select]
(cons 10 (cdr (assoc 10 numEL)))
What I want is to take the value of the dxfcode 10 from the entity I assigned as 'numEL' which is a selection set defined here:
Code: [Select]
(setq numEL (entget (ssname number 0)))
Should that not satisfy the (assoc element alist) ?

If I understand right, I'm giving it 'numEL' which is the association list of 'number'

So if I am telling it to construct a dotted list, (10 . [using cdr to return everything past the first value of the dxf group code 10])

I don't understand why it breaks :(

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: [Newb Help] Filter Objects using dxf code value
« Reply #8 on: May 01, 2009, 05:23:05 PM »
Can you post a small sample dwg?

Or, if you want to troubleshoot it yourself, get to stepping through the code in the VLIDE with a watch on those variables. You will/should quickly find the source of the problem.

James Cannon

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #9 on: May 01, 2009, 05:32:27 PM »
heh, I admit, I couldn't get the VLIDE to work for me... 'step into' is greyed out and I have no idea how to use this thing, tbh.

It just shot out
Code: [Select]
Command: ; error: bad DXF group: (10)
I saw what I did though, it was a stupid mistake I wasn't paying attention to.

I got it to run "successfully" without error, though the results are not what I desired, completely.

I'm going to see what I can do with it, and may be back if I get stuck.

Thank you so much so far, for everything by the way, everyone.

James Cannon

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #10 on: May 01, 2009, 05:41:00 PM »
sample I'm working with attached:

and what I'm working with at the moment:
Code: [Select]
(defun SurveyCleaner()

;;;--- ACTIONS TO BE EXECUTED FOR EACH ITEM SELECTED IN THE 'PointFix' routine below
(setq number(ssget "_X" '((62 . 4)(8 . "PT")))) ;;;---selection set of objects color 'cyan' layer PT
(setq elev(ssget "_X" '((62 . 7)(8 . "PT")))) ;;;---selection set of objects color 'white' layer PT
(setq desc(ssget "_X" '((62 . 3)(8 . "PT")))) ;;;---selection set of objects color 'green' layer PT
(setq node(ssget "_X" '((62 . 256)(8 . "PT")))) ;;;---selection set of objects color 'ByLayer' layer PT

(setq numEL (entget (ssname number 0)))
(setq eleEL (entget (ssname elev 0)))
(setq desEL (entget (ssname desc 0)))
(setq nodEL (entget (ssname node 0)))

;;;--- CREATE 'NEWNUMBER'
(setq newnumber(list
(cons 0 "MTEXT")
(cons 8 "SRVY-POINT-No")
(cons 100 "AcDbMText")
(cons 62 256)
(cons 7 "SurveyData")
(cons 40 12.0)
(cons 41 1.0)
(cons 42 1.0)
(cons 50 0.0)
(cons 10 (cdr (assoc 10 numEL)))
(cons 1 (cdr (assoc 1 numEL)))
)
)
(entmake newnumber)


;;;--- CREATE 'NEWELEV'
(setq newelev(list
(cons 0 "MTEXT")
(cons 8 "SRVY-POINT-ELEV")
(cons 100 "AcDbMText")
(cons 62 256)
(cons 7 "SurveyData")
(cons 40 12.0)
(cons 41 1.0)
(cons 42 1.0)
(cons 50 0.0)
(cons 10 (cdr (assoc 10 eleEL)))
(cons 1 (cdr (assoc 1 eleEL)))
)
)
(entmake newelev)




;;;--- CREATE 'NEWDESC'
(setq newdesc(list
(cons 0 "MTEXT")
(cons 8 "SRVY-POINT-DESC")
(cons 100 "AcDbMText")
(cons 62 256)
(cons 7 "SurveyData")
(cons 40 12.0)
(cons 41 1.0)
(cons 42 1.0)
(cons 50 0.0)
(cons 10 (cdr (assoc 10 desEL)))
(cons 1 (cdr (assoc 1 desEL)))
)
)
(entmake newdesc)

;;;--- CREATE 'NEWNODE'
(setq newnode(list
(cons 0 "POINT")
(cons 8 "SRVY-POINT-NODE")
(cons 100 "AcDbEntity")
(cons 62 256)
(cons 10 (assoc 10 nodEL))
)
)
(entmake newnode)
(princ)
)

;;;------------------------------------
;;;------------------------------------
;;;------------------------------------

(defun C:pointfix()
;;;--- CREATE NEW LAYERS REQUIRED
(command "-style" "SurveyData" "RomanS" 0 1 0 "No" "No" "No")
(command "-layer" "m" "SRVY-POINT-No" "C" 7 "" "")
(command "-layer" "m" "SRVY-POINT-ELEV" "C" 32 "" "")
(command "-layer" "m" "SRVY-POINT-DESC" "C" 52 "" "")
(command "-layer" "m" "SRVY-POINT-NODE" "C" 62 "" "")
(command "-layer" "m" "SRVY-TEMP-PT" "C" 3 "" "")

;;;--- 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)
)

James Cannon

  • Guest
Re: [Newb Help] Filter Objects using dxf code value
« Reply #11 on: May 01, 2009, 05:52:45 PM »
ok, everything is working as planned.

I neglected to put

   (cons 100 "AcDbEntity")
in there before I defined it as mtext.

That meant it didn't create the text at all.

I have not completed the point though, but that'll come Monday, it's 5pm right now, and I have a son to go see.

Thank you all for the help, this is a very successful routine.
I might have to tackle reading the comma delineated .asc file he sends next.  Likely by defining an attributed block in our library and setting the value of the attributes from the comma-delineated info he sends us.  Easy peasy, right?  Hopefully, so!

Thanks all, have a good weekend.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: [Newb Help] Filter Objects using dxf code value
« Reply #12 on: May 01, 2009, 06:25:35 PM »
I think that revising the function to be like this is more what you are trying to do, Josh. I didn't change the text height (assoc 40) because it is 0.6 now, but you were changing it to 12....big difference. But, it would be simple to add that into the mix, too.
Code: [Select]
(defun SurveyCleaner(/ DESC DESEL ELEEL ELEV NODE NODEL NUMBER NUMEL)

;;;--- ACTIONS TO BE EXECUTED FOR EACH ITEM SELECTED IN THE 'PointFix' routine below
(setq number(ssget "_X" '((62 . 4)(8 . "PT")))) ;;;---selection set of objects color 'cyan' layer PT
(setq elev(ssget "_X" '((62 . 7)(8 . "PT")))) ;;;---selection set of objects color 'white' layer PT
(setq desc(ssget "_X" '((62 . 3)(8 . "PT")))) ;;;---selection set of objects color 'green' layer PT
(setq node(ssget "_X" '((62 . 256)(8 . "PT")))) ;;;---selection set of objects color 'ByLayer' layer PT

(setq numEL (entget (ssname number 0)))
(setq eleEL (entget (ssname elev 0)))
(setq desEL (entget (ssname desc 0)))
(setq nodEL (entget (ssname node 0)))

  (setq numEL (subst (cons 7 "SurveyData") (assoc 7 numEL) numEL)
numEL (subst (cons 8 "SRVY-POINT-No") (assoc 8 numEL) numEL)
numEL (subst (cons 62 256) (assoc 62 numEL) numEL)
)

  (entmod numEL)

  (setq eleEL (subst (cons 7 "SurveyData") (assoc 7 eleEL) eleEL)
eleEL (subst (cons 8 "SRVY-POINT-ELEV") (assoc 8 eleEL) eleEL)
eleEL (subst (cons 62 256) (assoc 62 eleEL) eleEL)
)
  (entmod eleEL)

  (setq desEL (subst (cons 7 "SurveyData") (assoc 7 desEL) desEL)
desEL (subst (cons 8 "SRVY-POINT-DESC") (assoc 8 desEL) desEL)
desEL (subst (cons 62 256) (assoc 62 desEL) desEL)
)

  (entmod desEL)

  (setq nodEL (subst (cons 7 "SurveyData") (assoc 7 nodEL) nodEL)
nodEL (subst (cons 8 "SRVY-POINT-NODE") (assoc 8 nodEL) nodEL)
nodEL (subst (cons 62 256) (assoc 62 nodEL) nodEL)
)

  (entmod nodEL)
  )

HTH, and have a good weekend

mkweaver

  • Bull Frog
  • Posts: 352
Re: [Newb Help] Filter Objects using dxf code value
« Reply #13 on: May 02, 2009, 03:01:59 AM »
heh, I admit, I couldn't get the VLIDE to work for me... 'step into' is greyed out and I have no idea how to use this thing, tbh.

It just shot out
Code: [Select]
Command: ; error: bad DXF group: (10)

In the vlide, go to the Debug pull down menu and check "Break On Error".  This will stop the running code when it errors, allowing you to check/adjust variable values.

Now run your code.  If/when it breaks, go to the View pulldown and pick "Error Trace".  In the resulting window you will see the last half dozen or so calls.  When you see something that doesn't look right, select it and right click, then "Call Point Source" or "Source Position".

This approach will vastly ease troubleshooting.

Mike

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: [Newb Help] Filter Objects using dxf code value
« Reply #14 on: May 03, 2009, 08:25:17 AM »
You could condense the layer and colour changing parts of your code to a local function with arguments, perhaps like this:

Code: [Select]
[color=RED]([/color][color=BLUE]defun[/color] SurveyCleaner  [color=RED]([/color]col newlay [color=BLUE]/[/color] ss eLst[color=RED])[/color]

  [color=RED]([/color][color=BLUE]if[/color] [color=RED]([/color][color=BLUE]setq[/color] ss [color=RED]([/color][color=BLUE]ssget[/color] [color=#ff00ff]"_X"[/color] [color=RED]([/color][color=BLUE]list[/color] [color=RED]([/color][color=BLUE]cons[/color] [color=#009900]62[/color] col[color=RED])[/color] [color=DARKRED]'[/color][color=RED]([/color][color=#009900]8[/color] . [color=#ff00ff]"PT"[/color][color=RED])[/color][color=RED])[/color][color=RED])[/color][color=RED])[/color]
    [color=RED]([/color][color=BLUE]foreach[/color] eLst  [color=RED]([/color][color=BLUE]mapcar[/color] [color=DARKRED]'[/color][color=BLUE]entget[/color] [color=RED]([/color][color=BLUE]mapcar[/color] [color=DARKRED]'[/color][color=BLUE]cadr[/color] [color=RED]([/color][color=BLUE]ssnamex[/color] ss[color=RED])[/color][color=RED])[/color][color=RED])[/color]
      [color=RED]([/color][color=BLUE]setq[/color] eLst [color=RED]([/color][color=BLUE]subst[/color] [color=RED]([/color][color=BLUE]cons[/color] [color=#009900]7[/color] [color=#ff00ff]"SurveyData"[/color][color=RED])[/color] [color=RED]([/color][color=BLUE]assoc[/color] [color=#009900]7[/color] eLst[color=RED])[/color] eLst[color=RED])[/color]
            eLst [color=RED]([/color][color=BLUE]subst[/color] [color=RED]([/color][color=BLUE]cons[/color] [color=#009900]8[/color] newlay[color=RED])[/color] [color=RED]([/color][color=BLUE]assoc[/color] [color=#009900]8[/color] eLst[color=RED])[/color] eLst[color=RED])[/color]
            eLst [color=RED]([/color][color=BLUE]subst[/color] [color=RED]([/color][color=BLUE]cons[/color] [color=#009900]62[/color] [color=#009900]256[/color][color=RED])[/color] [color=RED]([/color][color=BLUE]assoc[/color] [color=#009900]62[/color] eLst[color=RED])[/color] eLst[color=RED])[/color][color=RED])[/color]
      [color=RED]([/color][color=BLUE]entmod[/color] eLst[color=RED])[/color][color=RED])[/color]
    [color=RED]([/color][color=BLUE]princ[/color] [color=#ff00ff]"\n<!> Nothing Found <!>"[/color][color=RED])[/color][color=RED])[/color]

  [color=RED]([/color][color=BLUE]princ[/color][color=RED])[/color][color=RED])[/color]

  [color=#990099];  Example:[/color]

[color=RED]([/color][color=BLUE]mapcar[/color] [color=DARKRED]'[/color]SurveyCleaner
        [color=DARKRED]'[/color][color=RED]([/color][color=#009900]4[/color] [color=#009900]7[/color] [color=#009900]3[/color] [color=#009900]256[/color][color=RED])[/color]
        [color=DARKRED]'[/color][color=RED]([/color][color=#ff00ff]"SRVY-POINT-No"[/color]
          [color=#ff00ff]"SRVY-POINT-ELEV"[/color]
          [color=#ff00ff]"SRVY-POINT-DESC"[/color]
          [color=#ff00ff]"SRVY-POINT-NODE"[/color][color=RED])[/color][color=RED])[/color]


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.