Vlisp in text/attribute field listing Autocad Version

Vlisp in text/attribute field listing Autocad Version

david.santos.tsgt
Contributor Contributor
1,934 Views
12 Replies
Message 1 of 13

Vlisp in text/attribute field listing Autocad Version

david.santos.tsgt
Contributor
Contributor

I have the need to list the AutoCAD version and drawing name in a Title Block or Mtext object.

The following code does exactly what I need, but the question is how do I include vlisp in Mtext or a Block? is there another approach to my need?

 

Code from jtbworld(dot)com:

(vla-get-caption (vlax-get-acad-object)) 

 

Thank you,

 

0 Likes
Accepted solutions (1)
1,935 Views
12 Replies
Replies (12)
Message 2 of 13

Moshe-A
Mentor
Mentor

David Hi,

 

you do need lisp or any macro to do that, explore text\mtext fields in online documentation.

 

Moshe

 

0 Likes
Message 3 of 13

Ranjit_Singh
Advisor
Advisor

If the software version does not change that often (for most of us it doesn't) make it a static text and use diesel expression in field to get rest of the data. For ex.

- [$(getvar,"dwgprefix")$(getvar,"dwgname")]
Message 4 of 13

david.santos.tsgt
Contributor
Contributor

In our company the product does vary a lot, users can be using AutoCAD, Civil 3D, AutoCAD P&ID or AutoCAD Electrical. 

And the code I posted does what I need but I need to incorporate it in Mtext or block with attributes.

 

The final goal is to display in Mtext or block something similar to this:

    Autodesk AutoCAD Civil 3D 2016 - [K:\\Site\\ProjectName\ProjectNumber\\Drawing003.dwg]

    Autodesk 2016 - [K:\\Site\\ProjectName\ProjectNumber\\Drawing002.dwg]

0 Likes
Message 5 of 13

Ranjit_Singh
Advisor
Advisor

The code shown in post 3 can be added to an attribute or mtext. However, I don't think there is a way to determine the vertical using diesel expression. Your only choice might be using a lisp function, and then calling it (or using some kind of reactor) before you open/save/print a drawing, to update the attributes.

0 Likes
Message 6 of 13

david.santos.tsgt
Contributor
Contributor

 

I'm familiar with adding Diesel expressions to text, rtext or attributes and the code in my original post it's a VLISP expression. That is the portion that needs to be implemented in Mtext or block.

Thanks, but I already know that DIESEL is not the solution.

 

0 Likes
Message 7 of 13

ActivistInvestor
Mentor
Mentor

@david.santos.tsgt wrote:

 

Thanks, but I already know that DIESEL is not the solution.

 


Are you sure about that?

 

   

Command: (setvar "MODEMACRO" "$(getvar,product) - [$(getvar,dwgprefix)$(getvar,dwgname)]")

 

Message 8 of 13

dbroad
Mentor
Mentor

To add to what @ActivistInvestor said, if you want the diesel in a field expression, it would just be this part:

$(getvar,product) - [$(getvar,dwgprefix)$(getvar,dwgname)]
Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 9 of 13

cadffm
Consultant
Consultant

He needs a tool to add the information by open a file to text/mtext/attrib,

 

 

variable product is not similar to (vla-get-caption (vlax-get-acad-object)) 

No Year/Version information (possible with acadver)

and no vertical-information, for example ACA 2018 => PRODUCT = "AutoCAD" (no word about ACA or 2018)

 

And a field is only meaningful if fieldeval is only set to 2 (may cause more problems as it makes sense to use value 2)

 

If I understand it correctly then an editor should be able to see with which version the file was last edited.
(How much worth the whole I left uncommented, or there is a kind of index-list in which EVERY save-process is documented)

 

Sebastian

Message 10 of 13

Moshe-A
Mentor
Mentor
Accepted solution

add the following code line to:

acaddoc.lsp or any custom.lsp file and load it from appload startup suite

 

(setvar "users5" (vla-get-caption (vlax-get-acad.object)))

 

than in your drawings use diesel code in RTEXT

$(getvar, users5)

 

this will work as long acaddoc.lsp will be exist and loaded into each drawing also RTEXT is an ExpressTools command

which also must be install on AutoCAD.

 

users5 is part of a group of 5 system variables of type string that exist in AutoCAD (USERS1-USERS5). infact you can use any of them for this purpose.

as long as no one else (other application/program) sets users5 for some thing else in middle of an AutoCAD session, this will work.

 

 

cheers

Moshe

 

 

 

 

Message 11 of 13

dbroad
Mentor
Mentor

@Moshe-A offered a very simple solution.  You would have to decide how to trigger it (on load or with a plot or save reactor).  Another approach that would use custom info in the summary information part of drawings is:

;;D. C. Broad, Jr. 1/12/2018
;;Add a custom property to the summary info called productverdwg
;;that would enable a field to use the drawing productverdwg property
;;to report product version and drawing information to titleblocks.
;;Could be run on load or triggered via a reactor to plot and save events.
(defun add_CI_PVD ( /  DB DOC SI VALUE)
  (setq doc (vla-get-ActiveDocument(vlax-get-acad-object))
	db (vla-get-database doc)
	si (vla-get-summaryinfo db)
	)
  (if (VL-CATCH-ALL-ERROR-P(vl-catch-all-apply 'vla-GetCustomByKey (list si "productverdwg" 'value)))
    (vla-AddCustomInfo si "productverdwg" (vla-get-caption (vlax-get-acad-object)))
    (vla-SetCustomByKey si "productverdwg" (vla-get-caption (vlax-get-acad-object)))
    )
  (princ))
Architect, Registered NC, VA, SC, & GA.
Message 12 of 13

david.santos.tsgt
Contributor
Contributor

Thank you all for the help, I think Moshe-A approach is what will work for this process. But dbroad solution is giving me ideas to tackle another issue on a different process. Again, thank you all for your time and share of  knowledge.

 

Best,

David Santos 

0 Likes
Message 13 of 13

ActivistInvestor
Mentor
Mentor

@david.santos.tsgt wrote:

Thank you all for the help, I think Moshe-A approach is what will work for this process. But dbroad solution is giving me ideas to tackle another issue on a different process. Again, thank you all for your time and share of  knowledge.

 

Best,

David Santos 


From what I can infer from your request, you shouldn't be using fields at all, because if the value you show in a DWG represents the most-recent product/version used to actually edit the file, then it may not be the product/version used to open the file for viewing, plotting, etc. Then there is the matter of batch plotting.

 

The value should be static, in an attribute, and be updated only when the file is saved (via a beginSave reactor notification).

 

For your use case, I don't think fields are needed at all.

 

 

0 Likes