Entmake a LWPOLYLINE

Discussion in 'AutoCAD' started by BillZ, Jan 25, 2005.

  1. BillZ

    BillZ Guest

    R2005:

    I know, I know, use VL functions so don't tell me that.
    What I'm trying to do is upgrade an old routine to LWP's quickly so I can switch over to plinetype = 2 on our system.
    The I will spend time on re-writing the routine to VLA.

    I got the entitiy in a var ent:
    So why doesn't this work?

    Command: (setq enn (entget ent))
    ((-1 . <Entity name: 7ec442f0>) (0 . "LWPOLYLINE") (330 . <Entity name:
    7ec4fcf8>) (5 . "18E") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
    "OUTSIDE") (100 . "AcDbPolyline") (90 . 22) (70 . 1) (43 . 0.0) (38 .
    0.00152582) (39 . 0.0) (10 33.7121 5.21243) (40 . 0.0) (41 . 0.0) (42 .
    -0.113237) (10 34.9326 4.93243) (40 . 0.0) (41 . 0.0) (42 . 0.113237) (10
    35.8916 4.71243) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 61.0871 4.71243) (40 .
    0.0) (41 . 0.0) (42 . 0.0) (10 60.7727 10.7124) (40 . 0.0) (41 . 0.0) (42 .
    0.0) (10 66.7809 10.7124) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 64.3509 20.3993)
    (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 60.7727 19.4831) (40 . 0.0) (41 . 0.0) (42
    0.0) (10 61.5449 23.0788) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 36.0911
    25.9934) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 26.2121 25.9934) (40 . 0.0) (41 .
    0.0) (42 . 0.0) (10 16.3331 25.9934) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10
    -9.12067 23.0788) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 -8.34842 19.4831) (40 .
    0.0) (41 . 0.0) (42 . 0.0) (10 -11.9266 20.3993) (40 . 0.0) (41 . 0.0) (42 .
    0.0) (10 -14.3567 10.7124) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 -8.34842
    10.7124) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 -8.66287 4.71243) (40 . 0.0) (41
    0.0) (42 . 0.0) (10 16.5327 4.71243) (40 . 0.0) (41 . 0.0) (42 . 0.113237)
    (10 17.4916 4.93243) (40 . 0.0) (41 . 0.0) (42 . -0.113237) (10 18.7121
    5.21243) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 26.2121 5.21243) (40 . 0.0) (41 .
    0.0) (42 . 0.0) (210 0.0 0.0 1.0))

    Command: (setq ty (cadr (entget ent)))
    (0 . "LWPOLYLINE")

    Command: (setq acent (nth 4 (entget ent)))
    (100 . "AcDbEntity")

    Command: (setq acpl (nth 8 (entget ent)))
    (100 . "AcDbPolyline")

    Command: (setq rest (member (assoc 90 (entget ent))(entget ent)))
    ((90 . 22) (70 . 1) (43 . 0.0) (38 . 0.00152582) (39 . 0.0) (10 33.7121
    5.21243) (40 . 0.0) (41 . 0.0) (42 . -0.113237) (10 34.9326 4.93243) (40 . 0.0)
    (41 . 0.0) (42 . 0.113237) (10 35.8916 4.71243) (40 . 0.0) (41 . 0.0) (42 .
    0.0) (10 61.0871 4.71243) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 60.7727 10.7124)
    (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 66.7809 10.7124) (40 . 0.0) (41 . 0.0) (42
    0.0) (10 64.3509 20.3993) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 60.7727
    19.4831) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 61.5449 23.0788) (40 . 0.0) (41 .
    0.0) (42 . 0.0) (10 36.0911 25.9934) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10
    26.2121 25.9934) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 16.3331 25.9934) (40 .
    0.0) (41 . 0.0) (42 . 0.0) (10 -9.12067 23.0788) (40 . 0.0) (41 . 0.0) (42 .
    0.0) (10 -8.34842 19.4831) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 -11.9266
    20.3993) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 -14.3567 10.7124) (40 . 0.0) (41
    0.0) (42 . 0.0) (10 -8.34842 10.7124) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10
    -8.66287 4.71243) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 16.5327 4.71243) (40 .
    0.0) (41 . 0.0) (42 . 0.113237) (10 17.4916 4.93243) (40 . 0.0) (41 . 0.0) (42
    -0.113237) (10 18.7121 5.21243) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 26.2121
    5.21243) (40 . 0.0) (41 . 0.0) (42 . 0.0) (210 0.0 0.0 1.0))

    Finally:

    Command: (entmake (apply 'append (list (list ty)(list acent)(list acpl) rest)))
    ((0 . "LWPOLYLINE") (100 . "AcDbEntity") (100 . "AcDbPolyline") (90 . 22) (70 .
    1) (43 . 0.0) (38 . 0.00152582) (39 . 0.0) (10 33.7121 5.21243) (40 . 0.0) (41
    0.0) (42 . -0.113237) (10 34.9326 4.93243) (40 . 0.0) (41 . 0.0) (42 .
    0.113237) (10 35.8916 4.71243) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 61.0871
    4.71243) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 60.7727 10.7124) (40 . 0.0) (41 .
    0.0) (42 . 0.0) (10 66.7809 10.7124) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10
    64.3509 20.3993) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 60.7727 19.4831) (40 .
    0.0) (41 . 0.0) (42 . 0.0) (10 61.5449 23.0788) (40 . 0.0) (41 . 0.0) (42 .
    0.0) (10 36.0911 25.9934) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 26.2121 25.9934)
    (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 16.3331 25.9934) (40 . 0.0) (41 . 0.0) (42
    0.0) (10 -9.12067 23.0788) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 -8.34842
    19.4831) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 -11.9266 20.3993) (40 . 0.0) (41
    0.0) (42 . 0.0) (10 -14.3567 10.7124) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10
    -8.34842 10.7124) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 -8.66287 4.71243) (40 .
    0.0) (41 . 0.0) (42 . 0.0) (10 16.5327 4.71243) (40 . 0.0) (41 . 0.0) (42 .
    0.113237) (10 17.4916 4.93243) (40 . 0.0) (41 . 0.0) (42 . -0.113237) (10
    18.7121 5.21243) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 26.2121 5.21243) (40 .
    0.0) (41 . 0.0) (42 . 0.0) (210 0.0 0.0 1.0))

    It spills out on the screen but new LWpoly does not appear.

    TIA

    Bill
     
    BillZ, Jan 25, 2005
    #1
  2. BillZ

    Jeff Mishler Guest

    Hmmm, works for me in R2002 (once I fixed a few bad assoc codes, 4 of them
    were missing the dot...must've been something in the cut-paste)
     
    Jeff Mishler, Jan 25, 2005
    #2
  3. BillZ

    BillZ Guest

    (once I fixed a few bad assoc codes, 4 of them
    were missing the dot<<<

    Which? The 10's?

    I'm working right off the variable so that should not be a problem here.

    Seems to me I've seen a post about lwp's and entmake but can't fine if now.

    Bill
     
    BillZ, Jan 25, 2005
    #3
  4. BillZ

    Jeff Mishler Guest

    No, 41 & 42's...they are ones at the end of line and in your post they show
    like this: (42
    0.0) which omits the dot (42 . 0.0), but as you say that shouldn't affect
    you....and besides, it throws a 'bad association' list error so you'd know
    right away.

    Another thought on this:
    If (entmake ;list) returns a list then the entity was created.....did you
    try zooming out? What does (entget (entlast)) return?

    From the help:
    If successful, entmake returns the entity's list of definition data. If
    entmake is unable to create the entity, it returns nil.
     
    Jeff Mishler, Jan 25, 2005
    #4
  5. BillZ

    BillZ Guest

    I don't know why it would not return nil.

    The in formation on the screen does not show any entity name, It's just a copy of what my list returns.

    (entget (entlast)) is the same at the entity picked and "erase all" shows no extra entities nor does "zoom e".


    BTW: the assoc 40 and 42 look okay on the web side.

    Thanks

    Bill
     
    BillZ, Jan 25, 2005
    #5
  6. BillZ

    BillZ Guest

    Jeff,

    I got it to work.
    Don't know exactly what it wanted but when I broke it down and reassembled the list it went.

    Code:
    (defun entmakelwpl ()
    (setq ent (car (entsel "\nSelect part"))
    )
    (setq vlst (vl-remove-if 'null (mapcar '(lambda (a)(if (= (car a) 10)(cdr a)))(entget ent)))
    blst (vl-remove-if 'null (mapcar '(lambda (a)(if (= (car a) 42)(cdr a)))(entget ent)))
    ptlt (apply 'append (mapcar '(lambda (a b)(list (cons 10 a)(cons 42 b))) vlst blst))
    nump (cons 90 (length vlst))
    swid (assoc 40 (entget ent))
    ewid (assoc 41 (entget ent))
    layr (assoc 8 (entget ent))
    ty (cadr (entget ent))
    acent (nth 4 (entget ent))
    acpl (nth 8 (entget ent))
    plcl (assoc 70 (entget ent))
    )
    
    
    (entmake (apply 'append (list
    (list ty)
    (list acent)
    (list layr)
    (list (cons 67 0))
    (list acpl)
    (list nump)
    ptlt
    (list swid)
    (list ewid)
    (list plcl)
    )
    )
    )
    )
    Go figure.

    Bill
     
    BillZ, Jan 25, 2005
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.