Sorry to ask such a trivial question but its hard to search for "if" "and" and "or". I need to write an if or statement. I need to perform a task if an entity is a lwpolyline or a circle. Thanks in advance.
|
Sorry to ask such a trivial question but its hard to search for "if" "and" and "or". I need to write an if or statement. I need to perform a task if an entity is a lwpolyline or a circle. Thanks in advance.
No need to apologise ... we all needed to learn from somewhere
If you have the entity data as you would after an entget, then this might do (assume edata is the list returned from entget):Another simpler way (no or needed - implied with comma "," in wcmatch):Code:(if (or (= (cdr (assoc 0 edata)) "LWPOLYLINE") (= (cdr (assoc 0 edata)) "CIRCLE") ) ;end of or (progn ;; Do what needs done with the PL or Circ ) ;end of progn (progn ;; Do what needs done if not a PL or Circ ) ;end of progn ) ;end of ifCode:(if (wcmatch (cdr (assoc 0 edata)) "LWPOLYLINE,CIRCLE") ;; continue as usual
Thanks, thats great. Very easy to do, but very hard to find out how to do it.
If you're doing LISP programming, what editor do you use? I'd advise using AutoCAD's built-in VLIDE. One nice thing here is, if the cursor's on a function name (such as if / or) you can press Ctrl+F1 and the developer help opens for that function.
This is one of the minor reasons I use VLIDE (instead of anything else), the major reasons:
- Automatic formatting & tabs
- Colouring code
- ***Most Important*** debugging code directly in AutoCAD