Author Topic: entmod not modifying  (Read 2226 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
entmod not modifying
« on: March 30, 2005, 12:22:34 PM »
I'm trying to throw together a little function that will take the xvalue of a list of selected objects, get the greatest xvalue of all objects and substitute that value into the xvalue of said objects. Here's what I have so far.
ename list should be a list of ename objects
Code: [Select]
(defun lineupText (enamelist / xval puttoval newlist)
     (setq xval    (mapcar '(lambda (x) (car (cdr (assoc 11 (entget x)))))
   enamelist
   )
  puttoval (car (vl-sort xval '>))
     )
     (mapcar '(lambda (x)
  (setq newlist (subst puttoval
(car (cdr (assoc 11 (entget x))))
(entget x)
)
  )
  (entmod newlist)
  (entupd x)
     )
    objs
     )
)

I'm sure this could be made cleaner, but this is just the first go around. Will someone please tell me why entmod isn't updating the list?
Thank you.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
entmod not modifying
« Reply #1 on: March 30, 2005, 12:39:39 PM »
Perhaps --

Code: [Select]
(defun LineUpText ( enames / x pair data )
     
    ;; get minimum x coordinate for all entities 11 group

    (setq x
        (apply 'min
            (mapcar
               '(lambda (ename) (cadr (assoc 11 (entget ename))))
                enames
            )    
        )
    )
   
    ;;  apply minx to all entities
   
    (foreach ename enames
        (entmod
            (subst
                (cons 11
                    (cons x
                        (cddr
                            (setq pair
                                (assoc 11
                                    (setq data (entget ename))
                                )
                            )    
                        )
                    )
                )
                pair
                data
            )
        )
        (entupd ename)
    )
     
    (princ)
   
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

daron

  • Guest
entmod not modifying
« Reply #2 on: March 30, 2005, 01:05:29 PM »
Okay, I see what I was doing wrong. I was adding just the value and needed to add the list. Doh! Nice code.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
entmod not modifying
« Reply #3 on: March 30, 2005, 01:07:38 PM »
Glad it helped, and thanks for the compliment.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst