Author Topic: Field not working after closing the file and open again  (Read 181 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1198
Field not working after closing the file and open again
« on: August 08, 2017, 10:58:11 am »
I amusing a lisp to copy a string as a field (I do not know the author)
but when close the file and open again the link broken
attached a file

Code - Auto/Visual Lisp: [Select]
  1. (defun C:CopyAsField (/ enam elst objid fldexp enm2)
  2.  (while (null (setq enam (car (nentsel "\nSelect TEXT/MTEXT/ATTRIBUTE: "))))
  3.    (princ "Nothing Selected")
  4.    )
  5.  (cond ((and
  6.   (setq elst (entget enam))
  7.   (setq elst (member  (cdr (assoc 0 elst)) '("ATTRIB" "TEXT" "MTEXT")))
  8.   (setq objid (vla-get-ObjectId (vlax-ename->vla-object enam)))
  9.   (setq fldexp (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa objid) ">%).TextString>%"))
  10.   (setvar "cmdecho" 0)
  11.   (progn (If (and (not (= glay ""))
  12.   (member glay (mapcar 'strcase (cons "MODEL" (layoutlist)))))
  13.    (setvar 'Ctab glay)) T)
  14.   (setq enm2 (car (nentsel "\nSelect String: ")))
  15.   (setq enam (member  (cdr (assoc 0 (entget enm2))) '("ATTRIB" "TEXT" "MTEXT")))
  16.   (not (vla-put-textstring (vlax-ename->vla-object enm2) fldexp))
  17.   (setvar "cmdecho" 1)
  18.   )
  19. )
  20. )
  21.    '(lambda (j) (if (null (eval (car j))) (princ (cadr j))
  22.   ))
  23.    '((elst "\nSelected Entity is Not valid for Field value.")
  24.      (enm2 "\nNothing Selected")
  25.      (enam "\nSelected Entity is Not valid for Field value."))
  26.    )
  27.  (princ)
  28.  )


ribarm

  • Water Moccasin
  • Posts: 1687
  • Marko Ribar, architect
Re: Field not working after closing the file and open again
« Reply #1 on: August 08, 2017, 11:45:49 am »
All I can say is that this issue smells like something described in these topics... So investigate - maybe the issue can be solved by saving variables in first session and then when opened another session saved variables can be loaded again so that the work can continue through another session like nothing between discontinued...

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/extract-a-text-from-a-long-text/m-p/5955380/highlight/true#M337556

https://www.theswamp.org/index.php?topic=50628.msg557923#msg557923

HTH., M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube