How to fill Var witch Lisp?

How to fill Var witch Lisp?

Anonymous
Not applicable
996 Views
1 Reply
Message 1 of 2

How to fill Var witch Lisp?

Anonymous
Not applicable

Hi, a little ask..

I need to fill a field like this, but with lisp.

%<\AcVar CustomDP.1º TÍTULO>%

I was trying this, no one works.

 

 

(defun c:June()
	(setq '%<\AcVar CustomDP.Nº PLANO>%' "Titulo 1")
)

Error: Sintaxis error

(defun c:June()
	(setq "%<\AcVar CustomDP.Nº PLANO>%" "Titulo 1")
)

Error: Sintaxis error

(defun c:June()
	(setq "CustomDP.Nº PLANO" "Titulo 1")
)

Error: Sintaxis error

 

I hope I have made myself understood

 

Thanks you.

 

 

0 Likes
Accepted solutions (1)
997 Views
1 Reply
Reply (1)
Message 2 of 2

CodeDing
Advisor
Advisor
Accepted solution

@Anonymous ,

 

I use these 2 functions to get / set my custom drawing properties:

(defun GetCustomDwgProp (key / acObj acDoc docProps return num keyVal propVal)
;key - string, representing key value of custom dwgprop to search for
;returns string of dwgprop value if found, or nil
(setq acObj (vlax-get-acad-object))
(setq acDoc (vla-get-ActiveDocument acObj))
(setq docProps (vla-get-SummaryInfo acDoc))
(setq return nil num 0)
(if (and (>= (setq total (vla-NumCustomInfo docProps)) 1)
	 (eq 'STR (type key)))
  (while (< num total)
    (vla-GetCustomByIndex docProps num 'keyVal 'propVal)
    (if (eq (strcase key) (strcase keyVal)) (setq return propVal))
    (setq num (1+ num))
  );while
);if
return
);defun

(defun SetCustomDwgProp (key val / acObj acDoc docProps return num keyVal propVal)
;key - string, representing key value of custom dwgprop to search for
;val - string, representing custom value to be used for the "key" custom dwgprop
;returns t if successful, or nil
(setq acObj (vlax-get-acad-object))
(setq acDoc (vla-get-ActiveDocument acObj))
(setq docProps (vla-get-SummaryInfo acDoc))
(setq return nil num 0)
(if (and (>= (setq total (vla-NumCustomInfo docProps)) 1)
	 (eq 'STR (type key))
	 (eq 'STR (type val)))
  (while (< num total)
    (vla-GetCustomByIndex docProps num 'keyVal 'propVal)
    (if (eq (strcase key) (strcase keyVal))
      (progn
	(vla-SetCustomByIndex docProps num keyVal val)
	(setq return t)
      );progn
    );if
    (setq num (1+ num))
  );while
);if
return
);defun

Example syntax call:

(defun c:TEST ( / x)
(SetCustomDwgProp "CustomProperty" "CustomValue")
(setq x (GetCustomDwgProp "CustomProperty"))
(alert x)
(princ)
);defun

Hope this helps! Best,

~DD

0 Likes