Page 1 of 5 12345 LastLast
Results 1 to 10 of 41

Thread: Nth item in DXF list

  1. #1
    Member
    Join Date
    2010-01
    Posts
    23
    Login to Give a bone
    0

    Default Change Nth item in DXF list

    Dear Readers,

    How can I change the Nth item in a DXF list.

    Voor example how can I change the vertices and width of a segment:
    ((-1 . <Entity name: 7ee4a828>) (0 . "LWPOLYLINE") (330 . <Entity name:
    7ee48cf8>) (5 . "3F5") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0")
    (100 . "AcDbPolyline") (90 . 6) (70 . 0) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10
    30.0 50.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 100.0 50.0) (40 . 0.0)
    (41 . 0.0) (42 . 0.0) (91 . 0) (10 100.0 120.0) (40 . 0.0) (41 . 0.0) (42 .
    0.0) (91 . 0) (10 170.0 120.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10
    170.0 50.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 270.0 50.0) (40 .
    0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0))

    With (setq dxf (entget (car (entsel))))
    (entmod (subst (cons 10 '(50 20))(assoc 10 dxf) dxf)),
    (entmod (subst (cons 40 2.0)(assoc 40 dxf) dxf)) and
    (entmod (subst (cons 41 3.5)(assoc 41 dxf) dxf)
    I get only the first vertex and witdh changed.

    Regards.
    Last edited by pvogt50; 2010-10-11 at 01:14 PM.

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Nth item in DXF list

    Hello.

    With function CDR you could get the second code.

    According to your examples,
    - First one,

    Code:
    (cdr (assoc 10 (entget (car (entsel)))))
    - Second one,

    Code:
    (cdr (assoc 40 (entget (car (entsel)))))
    Hope this what you look for.

    Tharwat

  3. #3
    Member
    Join Date
    2010-01
    Posts
    23
    Login to Give a bone
    0

    Default Re: Nth item in DXF list

    Quote Originally Posted by tharwat313 View Post
    Hello.

    Hope this what you look for.

    Tharwat
    Dear Tharwat,

    I changed my thread, where you can see that I mean something else.
    I would like to change all vertices and all widths.

    Regards.
    Last edited by pvogt50; 2010-10-11 at 11:48 AM.

  4. #4
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Nth item in DXF list

    Quote Originally Posted by pvogt50 View Post
    Dear Tharwat,

    I changed my thread, where you can see that I mean something else.
    I would like to change all vertices and all widths.

    Regards.
    what about using a different approach and using vlisp to change the polyline properties?

  5. #5
    Member
    Join Date
    2010-01
    Posts
    23
    Login to Give a bone
    0

    Default Re: Nth item in DXF list

    Quote Originally Posted by ccowgill View Post
    what about using a different approach and using vlisp to change the polyline properties?
    Dear Ccowgill,

    I think that the method with subst is more general,
    and for example also on tables can be applied.
    Furthermore I am rather unknown with Visual Lisp.
    The subroutine where I am in search of, is lost.

    Regards

  6. #6
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: Nth item in DXF list

    Quote Originally Posted by pvogt50 View Post


    I would like to change all vertices and all widths.
    Keep walking the list until you run out of group 10's
    Each 10 should be followed by a 40, 41 and 42.
    Last edited by rkmcswain; 2010-10-11 at 05:26 PM. Reason: fix quote
    R.K. McSwain | CAD Panacea |

  7. #7
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: Nth item in DXF list

    If you know the 10 value, you can use member to return the subsequent bulge/width values (41, etc.).

  8. #8
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    0

    Default Re: Nth item in DXF list

    If you would like to change all vertices and all widths of a polyline, analyze this lsp routine...
    Attached Files Attached Files

  9. #9
    100 Club
    Join Date
    2005-09
    Posts
    111
    Login to Give a bone
    0

    Default Re: Nth item in DXF list

    Quote Originally Posted by pvogt50 View Post
    Dear Ccowgill,

    I think that the method with subst is more general,
    and for example also on tables can be applied.
    Furthermore I am rather unknown with Visual Lisp.
    The subroutine where I am in search of, is lost.

    Regards
    Like this:
    Code:
    (defun ChNthDxf	(e n code value / ed newDxf i)
      (setq	ed     (entget e)
    	newDxf '()
      )
      (setq i 1)
      (foreach v ed
        (if	(= (car v) code)
          (progn
    	(if (= i n)
    	  (setq newDxf (cons (Cons code value) newDXf))
    	  (setq newDxf (cons v newDxf))
    	)
    	(setq i (1+ i))
          )
          (setq newDxf (cons v newDxf))
        )
      )
      (entmod (reverse newDXf))
      (entupd e)
    )
    Code:
    (defun c:Demo ()
      (command "_.ERASE" "_ALL" "")
      (command "_.PLINE" "35,35" "_W" "0" "" "@70<0"
    	   "@70<90" "@70<0"   "@70<270" "_W" "2" "2"
    	   "@70<0" "_W" "0" "" "@70<90" "@70<0"
    	   "@70<270" "@70<0"   ""
    	  )
      (command "_.ZOOM" "_ALL")
      (princ
        "\nNo constant Width because DXF code 43 must not set.\n"
      )
      (setq e (entlast))
      (command "_.DELAY" "700")
      (ChNthDxf e 2 10 '(120 80))
      (command "_.DELAY" "700")
      (ChNthDxf e 9 10 '(300 80))
      (command "_.DELAY" "700")
      (ChNthDxf e 3 40 5.0)
      (command "_.DELAY" "2000")
      (ChNthDxf e 3 41 22.0)
      (command "_.DELAY" "700")
      (ChNthDxf e 7 40 22.0)
      (command "_.DELAY" "2000")
      (ChNthDxf e 7 41 5.0)
      (princ
        "\nNo constant Width because DXF code 43 must not set."
      )
      (princ)
    )
    HofCAD CSI
    Last edited by hofcad; 2010-10-12 at 06:27 PM.

  10. #10
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: Nth item in DXF list

    Interesting approach (slight modification - will now accept more than one nth value to replace).

    Code:
    (defun foo (ent lst)
      ;; eg. (foo <ENAME> '( (0 (10 . "VALUE")) (3 (0 . "VALUE")) ))
      (if (eq (type ent) 'ENAME)
        (entupd (cdr (assoc -1
                            (entmod ((lambda (i)
                                       (mapcar
                                         (function (lambda (x)
                                                     (cond ((cadr (assoc (setq i (1+ i)) lst)))
                                                           (x)
                                                     )
                                                   )
                                         )
                                         (entget ent)
                                       )
                                     )
                                      -1
                                    )
                            )
                     )
                )
        )
      )
    )
    The lst variable is a list of sublists, consisting of the nth value at which to be replaced and the replacement dotted pair.
    Last edited by alanjt; 2010-10-13 at 06:38 PM.

Page 1 of 5 12345 LastLast

Similar Threads

  1. List Box Item = ImageName
    By wpeacock in forum VBA/COM Interop
    Replies: 7
    Last Post: 2010-05-17, 07:26 PM
  2. Here is my Wish List item for the next go round.
    By dmarx in forum AutoCAD Civil 3D - General
    Replies: 2
    Last Post: 2006-02-21, 04:47 PM
  3. Trusses - wish list item
    By erikbjur in forum Revit Structure - Wish List
    Replies: 10
    Last Post: 2006-02-14, 03:58 AM
  4. Trusses - wish list item
    By erikbjur in forum Revit Structure - General
    Replies: 5
    Last Post: 2006-01-19, 03:07 PM
  5. List item deliting
    By E-Key in forum Revit Architecture - Wish List
    Replies: 0
    Last Post: 2005-11-11, 02:51 PM

Posting Permissions

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