Help Needed with a Title block Field and Diesel Expressions

Help Needed with a Title block Field and Diesel Expressions

gmaine5Q4K6
Contributor Contributor
496 Views
5 Replies
Message 1 of 6

Help Needed with a Title block Field and Diesel Expressions

gmaine5Q4K6
Contributor
Contributor

Wondering if those of you who have more experience with Diesel Expressions might be able to tell me if the following idea is feasible: I am working on updating our company AutoCAD title blocks and templates this week, and we have an input for "Drawn By" in our blocks that should indicate the originator of the drawing, though many are not so good about filling this part out. In an attempt to rectify this, I wanted insert a field to pull the login name or better yet, their initials, and landed on the expression shown in this thread here as a potential solution: https://forums.autodesk.com/t5/autocad-forum/field-login-can-i-change-content-of-it/td-p/5197629 

 

I customized that expression to be "$(upper,$(substr,$(getvar,loginname),1,1) $(substr,$(getvar,loginname),2,5))" which outputs my first initial, and last name with a space between, which would be adequate for our needs. However, a coworker pointed out, and we tested this to see if it's the case, that anybody who opens the drawing will cause the field to update to their name. That said, is there a way to set this up to capture the name of the initial draftsperson and not just anybody who opens the drawing? Please and Thank you for any thoughts on this.      

0 Likes
Accepted solutions (1)
497 Views
5 Replies
Replies (5)
Message 2 of 6

paullimapa
Mentor
Mentor

Well, that's how FIELDS work. They automatically update. If another user opens the dwg, that FIELD will update based on that user's login.

Just a thought...if you only want this to occur when the dwg is first created, then you'll have to somehow force a lisp code to run whenever a new dwg is created to automatically fill out the DWGPROPS's Author entry with the loginname and then the FIELD command can be used to reference that:

paullimapa_0-1727286204642.png

paullimapa_1-1727286235955.png

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 6

CADaSchtroumpf
Advisor
Advisor

For to completing paullimapa

An exemple of code:

((lambda ( / AcDoc Space db sinfo)
	(setq
		AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
		Space
		(if (eq (getvar "CVPORT") 1)
			(vla-get-PaperSpace AcDoc)
			(vla-get-ModelSpace AcDoc)
		)
		db (vla-get-Database AcDoc)
		sinfo (vla-get-SummaryInfo db)
	)
	(if (eq (vla-get-Author sinfo) "")
		(vla-put-Author sinfo (strcat (strcase (substr (getvar "loginname") 1 1)) (strcase (substr (getvar "loginname") 2 5) T)))
	)
	(initget 1)
	(vla-addMtext Space
		(vlax-3d-point (getpoint "\nGive a point: "))
		(getvar "TEXTSIZE")
		"%<\\AcVar Author>%"
	)
))
Message 4 of 6

Sea-Haven
Mentor
Mentor
Accepted solution

Its not what your asking but you can obviously put the attribute value in a Title block based on user names etc. It does rely on the user running say a lisp. Ok suggestion we used a plot lisp so it could check is the Drawn by not blank, if so fill in, then plot.

 

We had 3rd party software so it would make lots of layouts obviously the title block had limited info so I wrote copy a title block attributes to all other layouts based on one title block. I guess what I am suggesting and you have hinted need people to adhere to company standards.

0 Likes
Message 5 of 6

gmaine5Q4K6
Contributor
Contributor

Yes, that always seems to be the answer, everybody needs to do what they're supposed to, and incentivizing that may be the ultimate solution.

0 Likes
Message 6 of 6

gmaine5Q4K6
Contributor
Contributor

I will give this a try, thank you!

0 Likes