+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Super Moderator Tiger's Avatar
    Computer Details
    Tiger's Computer Details
    Operating System:
    Windows 7 Enterprise 64 bit
    Computer:
    Dell Precision M4500
    CPU:
    Intel Core i5 2.40GHz
    RAM:
    8GB
    Graphics:
    NVIDIA Quadro FX 880M
    Primary Storage:
    280 GB
    Monitor:
    2 x Samsung SyncMaster 2443 24''
    Using
    AutoCAD 2012
    Join Date
    Nov 2006
    Location
    Sthlm, Sweden
    Posts
    4,595

    Wink Put 2 and 2 together

    Registered forum members do not see this ad.

    I've been racking my brain all day - and now I think the Americans are waking up, so I mind as well as a Q!

    I have done my very first LISP today (woohoo) to get AutoCAD 2006 to list coordinates on a polyline. And I have also got a LISP that inserts a line into each point I give it - now: How do I combine the two? That is to insert a line on each point of the polyline?

    To make it clearer, here is what I've got:

    Code:
    (defun c:coord (/ e len n e1)
     (setq e (entget (car (entsel))))
     ;get the entity list
     (setq len (length e))
     ;get the length of the list
     (setq n 0)
     ;set counter to zero
     (repeat len
     ;repeat for the length of the entity list
       (setq e1 (car (nth n e)))
       ;get each item in the entity list
       ;and strip the entity code number
       (if (= e1 10)
       ;check for code 10 (vertex)
         (progn
         ;if it's group 10 do the following
      (terpri)
        ;new line
        (princ (cdr (nth n e)))
        ;print the co-ordinates
     
         );progn
       );if
       (setq n (1+ n))
       ;increment the counter
     );repeat
      (princ)
    );defun
    (princ)
     
     
     
    (defun c:lines ()
    ;input
     (setq k1 (getpoint "\nPunkt 1: "))
     (setq k2 (getpoint "\nPunkt 2: "))
     (setq k3 (getpoint "\nPunkt 3: "))
     (setq k4 (getpoint "\nPunkt 4: "))
     
    ;polarpunkter
     (setq j1 (polar k1 (dtr 90) 50))
     
     (setq j2 (polar k2 (dtr 90) 50)) 
     (setq j3 (polar k3 (dtr 90) 50))
     (setq j4 (polar k4 (dtr 90) 50))
     
    ;line
     (command "Line" k1 j1 ""
       "Line" k2 j2 ""
       "Line" k3 j3 ""
       "Line" k4 j4 ""
    )
     
     (princ)
    )
    ;grader till radianer
    (defun dtr (x)
      (* pi (/ x 180.0))
    )
    Life doesn't suck, although we all go through periods when it may be easier to think that, than to discern the solution to whatever problem is the most formidable
    at the moment in one's personal UCS.
    Go to PLAN view instead. - Dadgad

  2. #2
    Forum Deity
    Using
    not specified
    Join Date
    Jul 2004
    Location
    Anchorage, Alaska
    Posts
    2,074

    Default

    You just want to draw a line at each vertex? Then just need a little modification of first routine:

    Change:
    (princ (cdr (nth n e)))


    to:

    (setq pt (cdr (nth n e)))
    (princ pt)
    (setq j2 (polar pt (dtr 90) 50))
    (command "Line" pt j2 "")

    And, include the 'dtr' defun with the first routine.

  3. #3
    Senior Member kpblc's Avatar
    Using
    AutoCAD 2005
    Join Date
    May 2006
    Location
    Russia, St-Petersburg
    Posts
    317

    Default

    To get coordinates of lightweightpolyline you can use this code:
    Code:
    (defun lwpline-get-coord (ent)
      (if (= (type ent) 'vla-object)
        (setq ent (vlax-vla-object->ename ent))
        ) ;_ end of if
      (if (= (cdr (assoc 0 (entget ent))) "LWPOLYLINE")
        (vl-remove-if '(lambda (x) (/= (car x) 10)) (entget ent))
        ) ;_ end of if
      ) ;_ end of defun
    Call parameters: ent - entity pointer (ename type)
    Call samples:
    Code:
    (lwpline-get-coord (car (entsel)))
    Something else: when you're drawing entities through (command) interface, set osmode to 0 before drawing. After drawing do not forget to restore it
    All I say is only my opinion.

  4. #4
    Senior Member
    Using
    AutoCAD 2005
    Join Date
    Sep 2006
    Posts
    106

    Default

    With a vla-object, you can use

    Code:
    (vlax-get ent 'coordinates)
    @+

  5. #5
    Senior Member kpblc's Avatar
    Using
    AutoCAD 2005
    Join Date
    May 2006
    Location
    Russia, St-Petersburg
    Posts
    317

    Default

    > Patrick_35 : And you'll get a variant which should be converted to array of doubles and atfer that convert it to list of points (2d or 3d). in case of lightweight polyline there is more simple to use (entget) functions.
    All I say is only my opinion.

  6. #6
    Senior Member
    Using
    AutoCAD 2005
    Join Date
    Sep 2006
    Posts
    106

    Default

    Simpler, I don't know.
    Sourer with the code dxf 10, yes. But it's especially por to avoid tranformer a vla object

    For a array of doubles
    Code:
    (setq xy (vlax-get ent 'coordinates))
    (while xy
      (setq lst (append lst (list (list (car xy) (cadr xy))))
             xy (member (caddr xy) xy))
    )
    @+

  7. #7
    Senior Member kpblc's Avatar
    Using
    AutoCAD 2005
    Join Date
    May 2006
    Location
    Russia, St-Petersburg
    Posts
    317

    Default

    (vlax-get) is undocumented method and it supporting could be stopped in next versions of AutoCAD (AFAIK). 'Cos of this i prefer not to use it (and vlax-put method also).
    All I say is only my opinion.

  8. #8
    Senior Member
    Using
    AutoCAD 2005
    Join Date
    Sep 2006
    Posts
    106

    Default

    Registered forum members do not see this ad.

    Perhaps, it functions since the version 2000

    @+

Bookmarks

Posting Permissions

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