Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need to prompt for block attributes on QNEW

19 REPLIES 19
SOLVED
Reply
Message 1 of 20
bcsurvey
564 Views, 19 Replies

Need to prompt for block attributes on QNEW

I'm further developing our template and would lke to know how much trouble it would be (if any) to be prompted for several block attributes upon a new file being created (QNEW).  The information in these blocks is found throughout the .dwg file and I'd like to reduce the amount of time going through each instance to modify (something that should have been done a long time ago).

 

Thanks!

Civil 3D 2019 (6.1)
Windows 10 Pro (21H2)
(i7-11850H @ 2.50 GHz)
32GB RAM
NVIDIA RTX A2000
19 REPLIES 19
Message 2 of 20
tcorey
in reply to: bcsurvey

You could add some code to ACADDOC.LSP that would check the file name. If it's Drawing*, prompt for attribute information, if the name is something else, it means this is not a new drawing, don't ask.

 

(if (=(substr(getvar "DWGNAME")1 7) "Drawing")

 

  (progn

    (ask for attributre info and fill in the blocks)

  );end progn

);end if

 

 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
Message 3 of 20
bcsurvey
in reply to: tcorey

Hey Tim,

     I was going through some old posts and came across this one.  I'd been wondering how what you provided could be accomplished and I may have just  overlooked it before . . .

 

I put this code in my acad2012doc.lsp file but I don't get the prompts for attributes.  Should the "Drawing" in the code be "Drawing*"?  Also, I understand that lisp language changed in recent acad versions so perhaps that's an issue for what you've posted?

 

Thanks!

Civil 3D 2019 (6.1)
Windows 10 Pro (21H2)
(i7-11850H @ 2.50 GHz)
32GB RAM
NVIDIA RTX A2000
Message 4 of 20
bcsurvey
in reply to: bcsurvey

I just spent about 10 minutes clicking around trying to find a way to edit my post above . . . no luck, so here's another one:

 

I'm a novice at best with regard to lisp, but I'm pretty sure that tcorey just put in only descriptions of functions, not the code itself.  I had copied it into my acad2012doc.lsp and was wondering why I wasn't getting prompted for attributes when I loaded a .dwg with "Drawing" in the file name.

 

If it wouldn't take too much time, can anyway give me the necessary code to output prompts for attributes.  Only a few attributes right now:  DRAFTER, TOWNSHIP, RANGE, SECTION, SURV_TYPE, CLIENT.

 

Thank you

Civil 3D 2019 (6.1)
Windows 10 Pro (21H2)
(i7-11850H @ 2.50 GHz)
32GB RAM
NVIDIA RTX A2000
Message 5 of 20
tcorey
in reply to: bcsurvey

No, you don't need the asterisk. The substr function with 1,7 means start at character 1 and go for 7 characters. Drawing is seven characters so any file that starts w drawing will meet the test.

If you can detail your wishes, next week will be slow for me and I can probably whip out the code you need to perform this task.

Best regards,

Tim


Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
Message 6 of 20
tcorey
in reply to: bcsurvey

(Setq drafter (getstring "backslashnEnter drafter name: "))

Use an actual backslash in the line above. My iPad keyboard doesn't have one. (Anyone know how to get a backslash on iPad?)

Using slash instead of backslash it would be (setq Drafter (getstring "/nEnter drafter name: "))

Just be sure to use the backslash. Backslash n is how you instruct the prompt to move to a new line in the command area.


Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
Message 7 of 20
bcsurvey
in reply to: tcorey

Thanks a bunch for that Tim.  I assume I sub that into (ask for attribute info and fill in the blocks)?

 

 

Civil 3D 2019 (6.1)
Windows 10 Pro (21H2)
(i7-11850H @ 2.50 GHz)
32GB RAM
NVIDIA RTX A2000
Message 8 of 20
Joe-Bouza
in reply to: bcsurvey

usually you get attribute prompts on insert not creating a new drawing?
My knee jerk reaction is SSM or fields. redifine the attributes in the template to use SSM fields if using SSM.
Thank you

Joseph D. Bouza, P.E. (one of 'THOSE' People)

HP Z210 Workstation
Intel Xeon CPU E31240 @ 3.30 Hz
12 GB Ram


Note: Its all Resistentialism, so keep calm and carry on

64 Bit Win10 OS
Message 9 of 20
tcorey
in reply to: bcsurvey

Without having complete details of what you're doing, I might miss something, but the following code will Prompt the user for Drafter, Date and Favorite Baseball Team. It will then fill this attribute information into all instances of a block called Baseball, which has three attributes.

 

This assumes that you are wanting to update blocks that already are inserted into the drawing, not those that simply exist in the block table (database.) Also, it assumes that there might be several instances of the block and so it steps through a selection set and updates them all. Either of these assumptions  could be way off, so this code is supplied as an example of how you would do this if those assumptions were true. Also, if you were in fact to want to use a Date attribute, you might consider using a Field in that attribute instead of using a prompt input. 

 

Best regards,

 

Tim

 

 

(if (=(substr(getvar "DWGNAME")1 7) "Drawing")
 
  (progn
    (setq Dftr (getstring "\nDrafter name: ")
	  Dte (getstring "\nDate: ")
	  Bball (getstring "\nFavorite Baseball Team: ")
	  )
    (setq ss (ssget "x" (list (cons 0 "INSERT")(cons 2 "BASEBALL")))   ;Cons 2 is the block name. Change this to your block name.
	  len (sslength ss)
	  ctr 0)

    (while (< ctr len)
      (setq blk (ssname ss ctr)
	    dftatt (entnext blk)
	    dteatt (entnext dftatt)
	    bballatt (entnext dteatt)
	    )

      (setq dftx (entget dftatt)
	    dtex (entget dteatt)
	    bballx (entget bballatt)
	    )

      (setq dftx (subst (cons 1 dftr)
			(assoc 1 dftx)
			dftx)
	    )
      (entmod dftx)

      (setq dtex (subst (cons 1 dte)
			(assoc 1 dtex)
			dtex)
	    )
      (entmod dtex)

      (setq bballx (subst (cons 1 bball)
			(assoc 1 bballx)
			bballx)
	    )
      (entmod bballx)
      (entupd blk)
      (setq ctr (1+ ctr))

      );end while
      
 
  );end progn
);end if
(setq dftr nil dte nil bball nil ss nil len nil ctr nil blk nil dftatt nil dteatt nil bballatt nil dftx nil dtex nil bballx nil)
(princ)

 

 

 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
Message 10 of 20
bcsurvey
in reply to: tcorey

Tim,

     I've customized the code you provided to fit the .dwg I'm using (block name, attributes, etc.), but still can't seem to hash it out.  I noticed you had 2 different variables referring to Drafter, so I corrected that (I think).  Here's what I have in my acad2012doc.lsp file (see below it for what I get in command line upon opening .dwg).  Perhaps something will stick out . . .

 

 

 

(if (=(substr(getvar "DWGNAME")1 7) "Drawing")
   (progn
    (setq dft (getstring "\nDrafter name: ")
	  dte (getstring "\nDate: ")
	  twn (getstring "\nTownship: ")
	  )
    (setq ss (ssget "x" (list (cons 0 "INSERT")(cons 2 "LispTest")))   ;Cons 2 is the block name. Change this to your block name.
	  len (sslength ss)
	  ctr 0)

    (while (< ctr len)
      (setq blk (ssname ss ctr)
	    dftatt (entnext blk)
	    dteatt (entnext dftatt)
	    twnatt (entnext dteatt)
	    )

      (setq dftx (entget dftatt)
	    dtex (entget dteatt)
	    twnx (entget twnatt)
	    )

      (setq dftx (subst (cons 1 dft)
			(assoc 1 dftx)
			dftx)
	    )
      (entmod dftx)

      (setq dtex (subst (cons 1 dte)
			(assoc 1 dtex)
			dtex)
	    )
      (entmod dtex)

      (setq twnx (subst (cons 1 twn)
			(assoc 1 twnx)
			Twnx)
	    )
      (entmod twnx)
      (entupd blk)
      (setq ctr (1+ ctr))

      ) ;end while
   ) ;end progn
) ;end if
(setq dft nil dte nil twn nil ss nil len nil ctr nil blk nil dftatt nil dteatt nil twnatt nil dftx nil dtex nil Twnx nil)
(princ)

 

This is what I get in command line after opening .dwg file:

 

AutoCAD menu utilities loaded. Drafter name: Command: C*Cancel* C Command: COMMANDLINE Date: properties Township: Command: *Cancel*

 

After this, if I do anything in the drawing, I immediately get a Fatal Error, consistently.  The code above is the only thing I've added to the .lsp file since original installation.

 

As I'm sure your time is money, I'll say that this is not a critical matter.  But I appreciate every second you can give me!

Civil 3D 2019 (6.1)
Windows 10 Pro (21H2)
(i7-11850H @ 2.50 GHz)
32GB RAM
NVIDIA RTX A2000
Message 11 of 20
bcsurvey
in reply to: bcsurvey

I forgot to post the second part the right way.  Here's what I get in command line at end of application open  . . .

 

AutoCAD menu utilities loaded.
Drafter name:
Command: C*Cancel*
C
Command: COMMANDLINE
Date: properties
Township:
Command: *Cancel*

 

Civil 3D 2019 (6.1)
Windows 10 Pro (21H2)
(i7-11850H @ 2.50 GHz)
32GB RAM
NVIDIA RTX A2000
Message 12 of 20
rl_jackson
in reply to: bcsurvey

Just a thought here, but have you looked into using Fields (i.e. Drawing Properties) to handle those repeat items.

 

This would require no special coding to speak of, and would be fill-in the blank. And for single or multi sheet drawing is fairly easy to implement.


Rick Jackson
Survey CAD Technician VI

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

Message 13 of 20
tcorey
in reply to: bcsurvey

I will need to find where the error occurs in the code and inspect the block and its attributes. I can help you most expediently by connecting with you via our remote tech support platform. Please feel free to phone me on Monday at 530.221.2994 and we can finish this off for you.

 

Tim

 

 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
Message 14 of 20
bcsurvey
in reply to: rl_jackson

RL,

Can you give me a quick run down on this process?  I've already gone into drawing properties and added some fields with defaults.  Is this information extractable within blocks? 

 

Tim,

Thanks for the contact info.  I'd like to see which of these methods will serve us best.  Either way, I'd like to get more familiar with each approach.  I found a few good Lisp tutorials through the Autodesk University files, and I'm sure there's a wealth of info available for free elsehwere.

 

Civil 3D 2019 (6.1)
Windows 10 Pro (21H2)
(i7-11850H @ 2.50 GHz)
32GB RAM
NVIDIA RTX A2000
Message 15 of 20
rl_jackson
in reply to: bcsurvey

When you create custom fields in the drawing properties tab, they can be used with text, mtext & attributes to fill in the blank so to speak.

 

For instance:

 

Lets say you have a custom property called JOB NO create a peice of text, and insert field or select the field option in the attribute, a dialogue will pops up, and you select the Field Name you created in the left side of the panel.

 

When you fill in the drawing properties, it fills the field in.

 

An yes you can use data extraction, to expose the data. (I do that with a parking count block)

 

field.png

 

This method basically give one location to fill in things, I do it for just about the entire title block, if I have multi-sheet surveys in one drawing file it pushes the data to each page as needed.

 

 


Rick Jackson
Survey CAD Technician VI

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

Message 16 of 20
bcsurvey
in reply to: tcorey

Tim,

     I'm going to be using a combo of what you and RL have provided:  Your code for the pop-up text box of DWGPROPS Summary, then the pop-up for the actual DWGPROPS dialogue, where users can input attributes.  This will apply only to file names with "Drawing" for chars. 1-7.

 

Thanks for the phone number - I'll keep it on hand as I may need to contact somebody in the near future (we have a new boss who knows C3D well from survey and design perspective).

Civil 3D 2019 (6.1)
Windows 10 Pro (21H2)
(i7-11850H @ 2.50 GHz)
32GB RAM
NVIDIA RTX A2000
Message 17 of 20
bcsurvey
in reply to: tcorey

Ok gents, I think I can put this one to bed with one more bit of information . . .

 

Below is what I have in my lsp file - two operations that work together.  The DWGPROPS I have qualified for those files named "Drawing" as stated.  But I can't seem to assign the same code for the Summary comments (provided by tcorey in this thread:  http://forums.autodesk.com/t5/AutoCAD-Civil-3D-General/Attach-message-to-a-dwg-file/td-p/3200556/hig...).

 

I tried putting the "(if (=(substr(getvar "DWGNAME")1 7) "Drawing")" before the (vl-load-com) in the first operation, but it not only didn't do what I hoped, but also prevented the second operation.

 

If I can get both of these to apply only to "Drawing" file names (1-7), I'll leave you guys alone and let you enjoy your New Year.

 

Thanks!

 

 

;;; Drawing Properties Summary comments text pop-up

(vl-load-com)

  (defun CommentsAtOpen( / curdoc docdb summ cmnt)
      (setq curdoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
      (setq docdb (vla-get-Database curdoc))
      (setq summ (vla-get-SummaryInfo docdb))
     
  
 
      (setq cmnt (vla-get-comments summ))
      (alert cmnt)
  
  (princ)
    );end defun
(commentsatopen)

;;; Drawing Properties dialogue window pop-up

(if (=(substr(getvar "DWGNAME")1 7) "Drawing")
   (command "DWGPROPS")
   )
(princ)

 

Civil 3D 2019 (6.1)
Windows 10 Pro (21H2)
(i7-11850H @ 2.50 GHz)
32GB RAM
NVIDIA RTX A2000
Message 18 of 20
tcorey
in reply to: bcsurvey

If you want to attached your acaddoc.lsp file, I'll take a look.



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
Message 19 of 20
bcsurvey
in reply to: tcorey

The part in question is what I pasted, but I'm attaching the whole thing for you here.

Again, the only thing left that I'd like is to qualify the "Drawing Properties Summary Comments text pop-up" operation for only those .dwg's with "Drawing" for first 7 characters (similar to last operation shown thereon).

 

Thanks!

Civil 3D 2019 (6.1)
Windows 10 Pro (21H2)
(i7-11850H @ 2.50 GHz)
32GB RAM
NVIDIA RTX A2000
Message 20 of 20
tcorey
in reply to: bcsurvey

You just need to add the If statement above the code that retrieves and diplays the comments:

 

;;; Drawing Properties Summary Comments text pop-up

(vl-load-com)
(if (=(substr(getvar "DWGNAME")1 7) "Drawing")
  (progn
  (defun CommentsAtOpen( / curdoc docdb summ cmnt)
      (setq curdoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
      (setq docdb (vla-get-Database curdoc))
      (setq summ (vla-get-SummaryInfo docdb))
     
  
 
      (setq cmnt (vla-get-comments summ))
      (alert cmnt)
  
  (princ)
    );end defun
(commentsatopen)
);end progn
);end if

 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report