TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: HasanCAD on October 27, 2015, 09:33:36 AM

Title: Need fresh eyes to ckeck this code
Post by: HasanCAD on October 27, 2015, 09:33:36 AM
This lisp select vport to get its scale put when paste in attribut not showing the field
Code - Auto/Visual Lisp: [Select]
  1. (defun c:CVS (/ enam elst objid fldexp enm2)
  2.         (vl-load-com)
  3.         (while (null (setq enam (car (nentsel "\nSelect Viewport: "))))
  4.                 (princ "Nothing Selected")
  5.         )
  6.   (cond ((and
  7.            (setq elst (entget enam))
  8.            (setq elst (member  (cdr (assoc 0 elst)) '("VIEWPORT")))
  9.            (setq objid (vla-get-ObjectId (vlax-ename->vla-object enam)))
  10.            (setq fldexp (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa objid) ".StandardScale2 \\f \" ""%en0" ">%"))
  11.  
  12.            (setvar "cmdecho" 0)
  13.            (progn (If (and (not (= glay ""))
  14.                            (member glay (mapcar 'strcase (cons "MODEL" (layoutlist)))))
  15.                     (setvar 'Ctab glay)) T)
  16.            (setq enm2 (car (nentsel "\nSelect String: ")))
  17.            (setq enam (member  (cdr (assoc 0 (entget enm2))) '("ATTRIB" "TEXT" "MTEXT")))
  18.            (not (vla-put-textstring (vlax-ename->vla-object enm2) fldexp))
  19.            (setvar "cmdecho" 1)
  20.            (vla-regen (vla-get-ActiveDocument (vlax-get-acad-object)) acActiveViewport)
  21.            )
  22.          )
  23.         )
  24.     '(lambda (j) (if (null (eval (car j))) (princ (cadr j))
  25.                    ))
  26.     '((elst "\nSelected Entity is Not valid for Field value.")
  27.       (enm2 "\nNothing Selected")
  28.       (enam "\nSelected Entity is Not valid for Field value."))
  29.     )
  30.   (princ)
  31.   )
Title: Re: Need frish eyes to ckeck this code
Post by: Tharwat on October 27, 2015, 09:51:52 AM
Might be this one :

">%).StandardScale2 \\f \" "

Title: Re: Need frish eyes to ckeck this code
Post by: HasanCAD on October 27, 2015, 10:52:56 AM
Might be this one :

">%).StandardScale2 \\f \" "

Sorry for that but not working
Could you add the
Code - Auto/Visual Lisp: [Select]
  1. (setq fldexp (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa objid) ".StandardScale2 \\f \" ""%en0" ">%"))
Title: Re: Need frish eyes to ckeck this code
Post by: ronjonp on October 27, 2015, 11:34:23 AM
Did not look to closely but this stood out:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:cvs (/ elst enam enm2 fldexp objid)
  2.   (while (null (setq enam (car (nentsel "\nSelect Viewport: ")))) (princ "Nothing Selected"))
  3.   (cond ((and (setq elst (entget enam))
  4.               (setq elst (member (cdr (assoc 0 elst)) '("VIEWPORT")))
  5.               (setq objid (vla-get-objectid (vlax-ename->vla-object enam)))
  6.               ;; RJP - reformatted field code
  7.               (setq fldexp (strcat "%<\\AcObjProp Object(%<\\_ObjId "
  8.                                    (itoa objid)
  9.                                    " >%).StandardScale2 \\f \"%en0\">%"
  10.                            )
  11.               )
  12.               ;; RJP - why this code? .. 'glay' is always nil
  13. ;;;       (setvar "cmdecho" 0)
  14. ;;;       (progn
  15. ;;;         (if (and (not (= glay "")) (member glay (mapcar 'strcase (cons "MODEL" (layoutlist)))))
  16. ;;;           (setvar 'ctab glay)
  17. ;;;         )
  18. ;;;         t
  19. ;;;       )
  20.               (setq enm2 (car (nentsel "\nSelect String: ")))
  21.               (setq enam (member (cdr (assoc 0 (entget enm2))) '("ATTRIB" "TEXT" "MTEXT")))
  22.               (not (vla-put-textstring (vlax-ename->vla-object enm2) fldexp))
  23.               ;; RJP - why this code? .. no command calls in this code
  24. ;;;       (setvar "cmdecho" 1)
  25.               (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acactiveviewport)
  26.          )
  27.         )
  28.   )
  29.   (vl-some '(lambda (j)
  30.               (if (null (eval (car j)))
  31.                 (princ (cadr j))
  32.               )
  33.             )
  34.            '((elst "\nSelected Entity is Not valid for Field value.")
  35.              (enm2 "\nNothing Selected")
  36.              (enam "\nSelected Entity is Not valid for Field value.")
  37.             )
  38.   )
  39.   (princ)
  40. )

Title: Re: Need frish eyes to ckeck this code
Post by: Jeff H on October 27, 2015, 11:49:00 AM
What are frish eyes?
Title: Re: Need frish eyes to ckeck this code
Post by: HasanCAD on October 27, 2015, 11:57:36 AM
What are frish eyes?

  :uglystupid2:  :whistling:  fresh
Title: Re: Need fresh eyes to ckeck this code
Post by: Cathy on October 28, 2015, 02:55:02 PM
Give this a try:
Code - Auto/Visual Lisp: [Select]
  1.            (setq fldexp (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa objid) ">%).StandardScale2 \\f \"%en0\">%"))
  2.  
Title: Re: Need frish eyes to ckeck this code
Post by: HasanCAD on October 28, 2015, 03:42:56 PM
Did not look to closely but this stood out:
Thanks ronjonp
Working perfect
Title: Re: Need fresh eyes to ckeck this code
Post by: HasanCAD on October 28, 2015, 03:44:34 PM
Give this a try:
Code - Auto/Visual Lisp: [Select]
  1.            (setq fldexp (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa objid) ">%).StandardScale2 \\f \"%en0\">%"))
  2.  
Thanks Cathy
Working perfect
Title: Re: Need frish eyes to ckeck this code
Post by: ronjonp on October 28, 2015, 04:20:59 PM
Did not look to closely but this stood out:
Thanks ronjonp
Working perfect
Glad to help :)