Insert content in the command line to change a dwgprops value

Insert content in the command line to change a dwgprops value

Anonymous
Not applicable
1,857 Views
6 Replies
Message 1 of 7

Insert content in the command line to change a dwgprops value

Anonymous
Not applicable

I tried to find a solution with some forum posts, but it doesn't work. I'm looking for a Lisp code which allows me to insert content in the command line to change some dwgprops values. I hope to be clear enough :S

 

(defun ChgDwgprops (  .... ?? )))

 

(ChgDwgprops '( (vla-addcustominfo dwgprops "TAG_10" "123")))))


For example: It works very well for me to change some attribute values - Thx alot Danny NL

Updating block attribute via command line - Thx Danny NL 

(defun UpdateAttributes (UA_UpdateList / UA_Selection UA_Block UA_ProcessList UA_NewValue)
   (if
      (setq UA_Selection (ssget "_X" '((0 . "INSERT")(66 . 1))))
      (progn
         (vla-StartUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
         (foreach UA_Entity (mapcar 'cadr (ssnamex UA_Selection))
            (if
               (setq UA_ProcessList (assoc (strcase (vla-get-EffectiveName (setq UA_Block (vlax-ename->vla-object UA_Entity)))) UA_UpdateList))               
               (foreach UA_Attribute (vlax-safearray->list (vlax-variant-value (vla-GetAttributes UA_Block)))
                  (if
                     (setq UA_NewValue (cadr (assoc (strcase (vla-get-TagString UA_Attribute)) (cadr UA_ProcessList))))
                     (vla-put-TextString UA_Attribute UA_NewValue)
                  )
               )
            )
         )
         (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
      )
   )
)

(UpdateAttributes '( ("BLOCKNAME_1" (("TAG_1" "123")("TAG_2" "xyz"))) ("BLOCKNAME_2" (("TAG_1" "---"))) ("BLOCKNAME_3" (("TAG_1" "xXx")("TAG_2" "ABC"))) ) )

 

0 Likes
Accepted solutions (2)
1,858 Views
6 Replies
Replies (6)
Message 2 of 7

vladimir_michl
Advisor
Advisor

You can also try the PROPULATE Express Tool.

 

Vladimir Michl, www.cadstudio.cz - www.cadforum.cz

 

Message 3 of 7

Anonymous
Not applicable

This is not the alternative I want to follow at the moment. The dwgprops values are coming from excel and will be inserted with a copy / paste in the autocad command line. Thank you for this idea Vladimir.

0 Likes
Message 4 of 7

pbejse
Mentor
Mentor

@Anonymous wrote:

This is not the alternative I want to follow at the moment. The dwgprops values are coming from excel and will be inserted with a copy / paste in the autocad command line. Thank you for this idea Vladimir.


 

I dont get that, paste the values on the command prompt and do what?

 

0 Likes
Message 5 of 7

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... The dwgprops values are coming from excel and will be inserted with a copy / paste in the autocad command line. ....


If you are talking about assigning custom properties in a drawing, as with the DWGPROPS command, I'm not sure that can be done through the command line [there's no -DWGPROPS command with hyphen prefix to use it without the dialog box].  But if there's a way to do it, what would be the format  of the information in Excel?  A property name in a cell and its value in another?  Both together in a single cell?  If so, separated by a space or some other character(s)?  Something else?  Post a sample of what you would be pasting in  at the command line.

Kent Cooper, AIA
0 Likes
Message 6 of 7

Anonymous
Not applicable
Accepted solution

Yes I want to assign custom properties in a drawing. I'm looking for a Lisp that can interpret a generated Excel line so that I could insert the Autocad command line:

 

Lisp in acad.lsp (ChgDwgprops)

 

Example of a generated Excel line to be inserted (copy/paste) in the autoCAD command line:

(vla-AddCustomInfo DwgProps "TAG22" "System" "TAG23" "1240")

 

Thx for help 🙂

 

0 Likes
Message 7 of 7

pbejse
Mentor
Mentor
Accepted solution

@Anonymous wrote:

Example of a generated Excel line to be inserted (copy/paste) in the autoCAD command line:

(vla-AddCustomInfo DwgProps "TAG22" "System" "TAG23" "1240")

🙂

 


 

I see, Assuming you already have the code for reading excel AND the lines are in the correct format [ unlike the one you posted, as it is now it will generate this error  "Too many actual parameters"]

 

 

;; Example result from reading the excel file.
(setq fromexcelfile
       '("(vla-AddCustomInfo DwgProps \"TAG23\" \"System\")"
	 "(vla-AddCustomInfo DwgProps  \"TAG24\" \"1240\")"
	)
)

;; convert the string and evaluate (foreach itm fromexcelfile (eval (read itm)) )

I cant tell for sure without ChgDwgprops lsp. but from the looks of it, you do need to "paste" the value to the command prompt, as the funcion doesnt accept any number of arguments [ now i understand why ]

 

If ChgDwgprops accepts two string arguments

 

(foreach lines fromexcelfile
	  (setq itm (read itm))
	  (ChgDwgprops (caddr itm) (cadddr itm))
	)

Translated to

 

 

  itm = (vla-AddCustomInfo DWGPROPS "TAG23" "System")
  (caddr itm) = "TAG23"
  (cadddr itm)	= "System"

 

 

or as list of string

 

(foreach lines fromexcelfile
	  (setq itm (read itm))
	  (ChgDwgprops (list (caddr itm) (cadddr itm)))
	)

 

 

 

Note: Dont really want to write an entirely new code if you dont mind posting the program here.

 

HTH