Jump to content
Rooster

Selecting all unclosed polylines

Recommended Posts

Rooster

I've been using several simple lisps like the one below to select various different objects using their object entities. What I'm wondering is can anyone help me to work out how to similarly select all unclosed (open) polylines? I've looked for an open/closed object entity but can't find one - does anyone have an answer?

 

;FILTERS TEXT BY STYLE
(defun c:fts(/ cSet)

 (setq cSet(ssget
              '((0 . "TEXT,MTEXT")(7 . "Standard"))
            ); end ssget
); end setq
 
 (if cSet
   (progn
     (princ(strcat "\n" (itoa(sslength cSet)) " found."))
     (sssetfirst nil cSet)
     ); end progn
    (princ "\nNothing found. ")
   ); end if
 (princ)
 ); end of c:fts

Share this post


Link to post
Share on other sites
ollie

flag value 1 = closed
flag value 0 = open
 (setq sset (ssget "x" (list(cons 0 "lwpolyline")(cons 70 flag))))

using your method

 

(setq cSet(ssget
              '((0 . "lwpolyline")(7 . "Standard")(70 . 1)
            ); end ssget
   ); end setq 

 

hope that helps

Share this post


Link to post
Share on other sites
ollie
Bear in mind that not all polylines that are joined start to end are "closed" :thumbsup:

 

A reference for what Ollie has provided:

 

http://autodesk.com/techpubs/autocad/acad2000/dxf/

 

PS> You don't need the DXF 7 in the LWPolylines. :)

 

Hehe Ididn't even notice the group 7

Share this post


Link to post
Share on other sites
Rooster

Thanks guys - just struggling a little with my limited knowldge of LISP to put that all together:

 

;FILTERS UNCLOSED POLYLINES
(defun c:fopl(/ cSet)

;flag value 1 = closed
;flag value 0 = open
(setq sset (ssget "x" (list(cons 0 "lwpolyline")(cons 70 flag))))

(setq cSet(ssget
              '((0 . "lwpolyline")(70 . 1)
            ); end ssget
   ); end setq
 
 (if cSet
   (progn
     (princ(strcat "\n" (itoa(sslength cSet)) " found."))
     (sssetfirst nil cSet)
     ); end progn
    (princ "\nNothing found. ")
   ); end if
 (princ)
 ); end of c:fopl

???

Share this post


Link to post
Share on other sites
Lee Mac

Ollies first example was just a reference to help you :)

 

This is all that is needed:

 

;FILTERS UNCLOSED POLYLINES
(defun c:fopl(/ cSet)

(setq cSet(ssget "_X" '((0 . "lwpolyline")(70 . 1))
            ); end ssget
   ); end setq
 
 (if cSet
   (progn
     (princ(strcat "\n" (itoa(sslength cSet)) " found."))
     (sssetfirst nil cSet)
     ); end progn
    (princ "\nNothing found. ")
   ); end if
 (princ)
 ); end of c:fopl

Share this post


Link to post
Share on other sites
Rooster

perfect! thanks fellas :)

Share this post


Link to post
Share on other sites
Lee Mac

Just out of interest, this is what it would look like in VL:

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:GetLwClsd [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] sSet cSet[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] sSet [b][color=RED]([/color][/b][b][color=BLUE]vla-get-SelectionSets[/color][/b]
              [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b]
                [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cSet
   [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-error-p[/color][/b]
            [b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-apply[/color][/b]
              [b][color=DARKRED]'[/color][/b][b][color=BLUE]vla-item[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] sSet [b][color=#ff00ff]"cSet"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]vlax-invoke[/color][/b] sSet [b][color=DARKRED]'[/color][/b]Add [b][color=#ff00ff]"cSet"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
         [b][color=RED]([/color][/b][b][color=BLUE]t[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-delete[/color][/b]
              [b][color=RED]([/color][/b][b][color=BLUE]vla-item[/color][/b] sSet [b][color=#ff00ff]"cSet"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]vlax-invoke[/color][/b] sSet [b][color=DARKRED]'[/color][/b]Add [b][color=#ff00ff]"cSet"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vla-select[/color][/b] cSet [color=Blue][b]acSelectionSetAll[/b][/color] [b][color=BLUE]nil[/color][/b] [b][color=BLUE]nil[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-variant[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray-fill[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-safearray[/color][/b]
         [color=Blue][b]vlax-vbInteger[/b][/color] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] [b][color=#009900]70[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-variant[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray-fill[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-safearray[/color][/b]
         [color=Blue][b]vlax-vbVariant[/b][/color] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"LWPOLYLINE"[/color][/b] [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]zerop[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-count[/color][/b] cSet[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\n"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]itoa[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Count[/color][/b] cSet[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=#ff00ff]" found."[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vla-Highlight[/color][/b] cSet [b][color=Blue]:vlax-true[/color][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<< Nothing Found >>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vla-delete[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]vla-item[/color][/b] sSet [b][color=#ff00ff]"cSet"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   

Share this post


Link to post
Share on other sites
wkplan

Hello all,

 

is there a way to apply a filter-filter?

 

In the way the ssget-function will only check on selected layers...

 

At the moment the function will count all open/closed polylines (depends on (70.x), even if the layer ist frozen/locked.

 

regards

Wolfgang

Share this post


Link to post
Share on other sites
Lee Mac

I suppose you would have to filter the set after it has been collected.

 

In AutoLISP, such functions as ssdel would work, in my VL example:

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:GetLwClsd [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] sSet doc lays cSet oLst[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] sSet [b][color=RED]([/color][/b][b][color=BLUE]vla-get-SelectionSets[/color][/b]
              [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] doc
                [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b]
                  [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
       lays [b][color=RED]([/color][/b][b][color=BLUE]vla-get-layers[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cSet
   [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-error-p[/color][/b]
            [b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-apply[/color][/b]
              [b][color=DARKRED]'[/color][/b][b][color=BLUE]vla-item[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] sSet [b][color=#ff00ff]"cSet"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]vlax-invoke[/color][/b] sSet [b][color=DARKRED]'[/color][/b]Add [b][color=#ff00ff]"cSet"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
         [b][color=RED]([/color][/b][b][color=BLUE]t[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-delete[/color][/b]
              [b][color=RED]([/color][/b][b][color=BLUE]vla-item[/color][/b] sSet [b][color=#ff00ff]"cSet"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]vlax-invoke[/color][/b] sSet [b][color=DARKRED]'[/color][/b]Add [b][color=#ff00ff]"cSet"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vla-select[/color][/b] cSet [color=Blue][b]acSelectionSetAll[/b][/color] [b][color=BLUE]nil[/color][/b] [b][color=BLUE]nil[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-variant[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray-fill[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-safearray[/color][/b]
        [color=Blue][b] vlax-vbInteger[/b][/color] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] [b][color=#009900]70[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-variant[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray-fill[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-safearray[/color][/b]
         [b][color=Blue]vlax-vbVariant[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"LWPOLYLINE"[/color][/b] [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]zerop[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-count[/color][/b] cSet[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] Obj cSet
       [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] lay [b][color=RED]([/color][/b][b][color=BLUE]vla-item[/color][/b] lays [b][color=RED]([/color][/b][b][color=BLUE]vla-get-layer[/color][/b] Obj[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [color=Blue][b]:vlax-true[/b][/color] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-lock[/color][/b] lay[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
               [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=Blue]:vlax-true[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-freeze[/color][/b] lay[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
         [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] oLst [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] Obj oLst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] oLst
       [b][color=RED]([/color][/b][b][color=BLUE]vla-RemoveItems[/color][/b] cSet
         [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-variant[/color][/b]
           [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray-fill[/color][/b]
             [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-safearray[/color][/b]
               [b][color=Blue]vlax-vbObject[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]1-[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]length[/color][/b] oLst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] oLst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\n"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]itoa[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Count[/color][/b] cSet[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=#ff00ff]" found."[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vla-Highlight[/color][/b] cSet [b][color=Blue]:vlax-true[/color][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<< Nothing Found >>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vla-delete[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]vla-item[/color][/b] sSet [b][color=#ff00ff]"cSet"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   

Share this post


Link to post
Share on other sites
wkplan

Lee,

 

this works perfect!

 

Thanks a lot

Wolfgang

Share this post


Link to post
Share on other sites
Lee Mac

Thanks Wolfgang,

 

There are much much shorter ways to accomplish the same thing in AutoLISP, but I just like to vary things a little.

 

In AutoLISP:

 

(defun c:GetLwClsd (/ ss lay)
 (if (setq ss (ssget "_X" '((0 . "LWPOLYLINE") (70 . 1))))
   (progn
     (foreach ent (mapcar 'cadr (ssnamex ss))
       (setq lay (tblsearch "LAYER"
                   (cdr (assoc 8 (entget ent)))))
       (if (or (eq 1 (logand 1 (cdr (assoc 70 lay))))
               (eq 4 (logand 4 (cdr (assoc 70 lay)))))
         (ssdel ent ss)))
     (princ (strcat "\n" (itoa (sslength ss)) " found."))
     (sssetfirst nil ss))
   (princ "\n<< Nothing Found >>"))
 (princ))

 

Lee

Share this post


Link to post
Share on other sites
ollie

Another way of filtering is an extension to my first post

 

(setq sset(ssget "X" ' ((-4  . "<AND)..other group data (-4 ."AND>"))))

 

You can also apply "" and "" with the same principal using almost any variation

Share this post


Link to post
Share on other sites
wkplan

Hello all,

 

is there a way for checking polylines only at the current layer?

(This would make sense to me, because there might be cases where only the working-layer is needed to check)

 

@Lee: i like your autolisp-variant, because it is shorter,

not fully understanding both of them...

 

@ollie: same point, how would you define "other group data"?

 

regards

 

Wolfgang

Share this post


Link to post
Share on other sites
ollie
Hello all,

 

is there a way for checking polylines only at the current layer?

(This would make sense to me, because there might be cases where only the working-layer is needed to check)

 

@Lee: i like your autolisp-variant, because it is shorter,

not fully understanding both of them...

 

@ollie: same point, how would you define "other group data"?

 

regards

 

Wolfgang

 

An example of this could be

 

 (setq sset (ssget "X" ' ((-4 . "<AND")
                                  (0 . "ARC")
                                  (8 . "Example layer")
                                  (40 . 15)
                                  (-4 . "AND>"))))

 

the above would only select arcs on Example layer that have a radius of 15

 

 

The dxf reference in the vlisp editor help contains information on each entity types dxf group codes

Share this post


Link to post
Share on other sites
David Bethel
Bear in mind that not all polylines that are joined start to end are "closed"

 

Lee, that can be true for LWPOLYLINEs not heavy POLYLINES.

 

Also, the filter (70 . 0) excludes splined, curved fit, and 3D plines. The (0 . "LWPOLYLINE") excludes heavy POLYLINES. -David

Share this post


Link to post
Share on other sites
Lee Mac

Something like this for a Current layer filter:

 

(defun c:GetLwClsd (/ ss lay)
 (if (setq ss (ssget "_X" (list '(0 . "LWPOLYLINE")
                                (cons 8 (getvar "CLAYER")) '(70 . 1))))
   (progn
     (foreach ent (mapcar 'cadr (ssnamex ss))
       (setq lay (tblsearch "LAYER"
                   (cdr (assoc 8 (entget ent)))))
       (if (or (eq 1 (logand 1 (cdr (assoc 70 lay))))
               (eq 4 (logand 4 (cdr (assoc 70 lay)))))
         (ssdel ent ss)))
     (princ (strcat "\n" (itoa (sslength ss)) " found."))
     (sssetfirst nil ss))
   (princ "\n<< Nothing Found >>"))
 (princ))

 

FYI, you needn't use the -4 filters in this case, as all criteria in the filter list need to be met by the object.

Share this post


Link to post
Share on other sites
Lee Mac
Lee, that can be true for LWPOLYLINEs not heavy POLYLINES.

 

Also, the filter (70 . 0) excludes splined, curved fit, and 3D plines. The (0 . "LWPOLYLINE") excludes heavy POLYLINES. -David

 

Thanks David, I was unaware of that point :)

Share this post


Link to post
Share on other sites
wkplan

Lee and ollie,

 

thank you again for your time and explanations.

 

After reading many docs, I tried to insert a simple (8 . CLAYER), now I see why this failed.

(Had to read the help file again, lerned something about the cons-statement)

 

One question again:

In the previous version, there was:

 

'((0 . "LWPOLYLINE") (70 . 1))))

 

Now I read:

 

(if (setq ss (ssget "_X" (list '(0 . "LWPOLYLINE")

(cons 8 (getvar "CLAYER")) '(70 . 0))))

 

I knew the second ' is necessary, because otherwise te lisp fails, but I have no idea why?

A help search for the ' doesn't work, so what in the heck is it for?

 

regards

Wolfgang

Share this post


Link to post
Share on other sites
Lee Mac

The apostrophe means that the statement following it is not evaluated by the interpreter (the thing that turns the code into computer talk), and is just taken at "face value".

 

hence:

 

'((0 . "LWPOLYLINE") (8 . "0"))

Is correct as there are no functions within the statement that need to be evaluated.

 

However:

 

'((0 . "LWPOLYLINE") (cons 8 "0"))

Is incorrect, as the "cons" statement will not be evaluated.

 

So, we can use:

 

(list '(0 . "LWPOLYLINE") (cons 8 "0"))

In which case, the first statement is not evaluated, but just taken as an argument for the "list" function, however, the second statement is now evaluated.

 

You can see other examples when using mapcar:

 

(mapcar '+ '(1 2 3) '(4 5 6))

The apostrophe in front of the "+" function, indicates that this function is to be treated as an argument for the mapcar function, instead of being evaluated on its own.

 

If you are still unsure, just ask.

 

Lee

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...