A couple of newbie lisp questions / requests

A couple of newbie lisp questions / requests

h_s_walker
Mentor Mentor
2,144 Views
39 Replies
Message 1 of 40

A couple of newbie lisp questions / requests

h_s_walker
Mentor
Mentor

My company is soon going to be getting LT2025 after being stuck on LT2016 for ages.

Now I know if I want settings to load up everytime I need to put them in the *doc.lsp file.

What do I need put in the lisp file to change the following?

MTEXTCOLUMN 0

HPANNO 1

PASTESPECMODE 1

Those 3 will do for starters.

 

OK next request

We get sent drawings from clients all the time and I use the RENAME command to put "XCLIENT " in front of every entity so that all client stuff gets shoved to the bottom of the dialog boxes.

Is there a lisp which can run through the renaming of everything in the client drawing without me have to go through each and every group of items?

 

Howard Walker
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


Left Handed and Proud

0 Likes
Accepted solutions (3)
2,145 Views
39 Replies
Replies (39)
Message 2 of 40

ronjonp
Advisor
Advisor

For you first question, you can format your variables in a list like so to set them:

 

(foreach var '((mtextcolumn 0) (hpanno 1) (pastespecmode 1))
(setvar (car var) (cadr var))
)

 

Put that in your startup and you should be good to go.

 

What are you renaming in the drawings? Layers and block or other items?

0 Likes
Message 3 of 40

h_s_walker
Mentor
Mentor

@ronjonp All items in the dialog box which pops up when you type RENAME.

Howard Walker
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


Left Handed and Proud

0 Likes
Message 4 of 40

john.uhden
Mentor
Mentor

@h_s_walker ,

Thank God you explained that.  I was wondering how you would rename a LINE.

So, from memory, you want to rename only objects that have a name, e.g.

Layers

Text styles

Dimstyles

MLstyles

Blocks

Linetypes (?)

Views

Layouts

Layer states

Layer filters

etc, etc, etc. (?)

John F. Uhden

0 Likes
Message 5 of 40

Kent1Cooper
Consultant
Consultant

@h_s_walker wrote:

....

We get sent drawings from clients all the time and I use the RENAME command to put "XCLIENT " in front of every entity so that all client stuff gets shoved to the bottom of the dialog boxes.

Is there a lisp which can run through the renaming of everything in the client drawing without me have to go through each and every group of items?


I suggest that you not open their drawings and do all that within them, but open a drawing of your own to contain all of that, which you can collectively rename all at once by this method:
Rename a drawing of theirs with XCLIENT prefixed to the drawing name [shorten the rest if you like, or replace all of it with just XCLIENT if there won't then be confusion among multiple drawings].

XREF that drawing into yours.

BIND that Xref using the Bind [not the Insert] option.

EXPLODE that after Binding, so it won't be a Block any more, and you can work with the pieces.

All those Renamable things [Layers, Block names, Text Styles, etc.] will end up with names as in your description, though starting with the XCLIENT-prefixed drawing name and a "pipe" character, not with just XCLIENT.

 

But depending on what you need to do in their drawings that also involves Layers and Styles and such of your own, consider simply XREFing, without Binding anything.  The Layer & Block & Style etc. names will still be prefixed with the drawing name they're part of, and therefore isolated amongst themselves in lists.

Kent Cooper, AIA
Message 6 of 40

john.uhden
Mentor
Mentor

@Kent1Cooper ,

Excellent!

But he must realize that if he wants to use that method on more than one xref that he must use a different prefix for each (unless it's okay to comingle).

John F. Uhden

0 Likes
Message 7 of 40

ronjonp
Advisor
Advisor

@h_s_walker 

Not knowing your exact workflow, I agree that using an XREF is the way to handle this. Renaming everything is a bit cumbersome ( as you know ) :).

0 Likes
Message 8 of 40

h_s_walker
Mentor
Mentor

Ah I should have explained a bit better.

We get drawings from our clients which contain floor plans. We then insert those floor plans into our drawings as blocks.

We may get a drawing which has 20 floor plans in, but we only need one.

@Kent1Cooper XCLIENT has a space after it

Howard Walker
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


Left Handed and Proud

0 Likes
Message 9 of 40

paullimapa
Mentor
Mentor

You can always first rename the client's dwg file with prefix "XCLIENT Floor Plan.dwg"

Then xref that dwg into your dwg and then BIND it.

Now all the "elements" will automatically be prefixed with the drawing name.

 


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

h_s_walker
Mentor
Mentor

But we don't want the whole client drawing, just a small part of it.

Also training the other workers to use xrefs would be a pain

Howard Walker
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


Left Handed and Proud

0 Likes
Message 11 of 40

paullimapa
Mentor
Mentor

You can always open the dwg and WBLOCK out the floor plan you need naming that dwg with the XCLIENT prefix name and then XREF that dwg in and then BIND.

But I'm in shock that you have co-workers that do not know how to use the very time saving XREF command.

Xrefs been around since Release 11 back in the early 90s. 


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

h_s_walker
Mentor
Mentor

I appreciate all the suggestions. BUT can someone just PLEASE do what I asked and give me a lisp I can use to rename all the items in the client's drawing

Howard Walker
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


Left Handed and Proud

0 Likes
Message 13 of 40

Kent1Cooper
Consultant
Consultant

@h_s_walker wrote:

.... we don't want the whole client drawing, just a small part of it. ....


This is what XCLIP is for.  Just show the small part, but put the whole thing in.  It doesn't cost you anything in memory consumption if it's an Xref -- all that's stored in the host drawing is the file path/name and insertion-type things like an ordinary Block [insertion point, scales, rotation].  It doesn't matter how big the Xref'd file is [this is part of the very purpose of Xrefs] -- all the memory consumption is out in that file, not in the host drawing.

 

And it has the huge advantage that if you get an updated base drawing file from the client, all your drawings will update themselves.  In what you are requesting, you would need to go through the entire process again every time, whether by overt renaming or via Xref/Bind or splitting up the base drawing into pieces or....

Kent Cooper, AIA
0 Likes
Message 14 of 40

h_s_walker
Mentor
Mentor

I know, but please can people stop giving suggestions and just give what I asked for.

Howard Walker
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


Left Handed and Proud

0 Likes
Message 15 of 40

Moshe-A
Mentor
Mentor

@Kent1Cooper hi,

This is what XCLIP is for.  Just show the small part, but put the whole thing in.  It doesn't cost you anything in memory consumption if it's an Xref -- all that's stored in the host drawing is the file path/name and insertion-type things like an ordinary Block [insertion point, scales, rotation].  It doesn't matter how big the Xref'd file is [this is part of the very purpose of Xrefs] -- all the memory consumption is out in that file, not in the host drawing.

Just to clarify, xref do cost memory in a middle of drawing session (a bit more than a block) and influence system performance and this is what important from user side (it doesn't matter if the host file size is small)

 

 

 

Message 16 of 40

ec-cad
Collaborator
Collaborator

"I know, but please can people stop giving suggestions and just give what I asked for."

 

With an attitude like that, probably not.

🙂

 

Message 17 of 40

MrJSmith
Advocate
Advocate
Accepted solution

Your mileage may vary since you didn't supply a test document.

 

 

(defun c:RenameNamedObjects ( / prefix acad namedDictionaries namedTables dictionary)
	(setq prefix "XCLIENT_")
	(setq acad (vla-get-activedocument (vlax-get-acad-object)))
	(setq namedDictionaries '("ACAD_DETAILVIEWSTYLE" "ACAD_MATERIAL" "ACAD_MLEADERSTYLE" "ACAD_SECTIONVIEWSTYLE" "ACAD_TABLESTYLE"))
	(setq namedTables '("blocks" "dimstyles" "layers" "linetypes" "textstyles" "usercoordinatesystems" "viewports" "views"))
	
	(vla-StartUndoMark acad)
	(vlax-for dictionary (vla-get-dictionaries acad) 
		(if (and 
				(vlax-property-available-p dictionary 'name)
				(vlax-property-available-p dictionary 'count)
				(member (vla-get-name dictionary) namedDictionaries)
			)
			(progn
				(vlax-for it dictionary
					(if (vlax-property-available-p it 'name)
						(progn 
							(vl-catch-all-apply '(lambda () (vla-put-name it (strcat prefix (vla-get-name it)))))
						)
					)
				)
			)
		)
	)
	(foreach table namedTables
		(setq dictionary (vlax-get-property acad table))
		(if (vlax-property-available-p dictionary 'count)
			(if (= table "textstyles") ;Text styles name property are read only, to change use the setpropertyvalue function
				(vlax-for it dictionary
					 (setpropertyvalue (vlax-vla-object->ename it) "Name" (strcat prefix (vla-get-name it)))
				)
				(vlax-for it dictionary
					(if (vlax-property-available-p it 'name)
						(vl-catch-all-apply '(lambda () (vla-put-name it (strcat prefix (vla-get-name it)))))
					)
				)
			)
		)
	)
	(vla-EndUndoMark acad)
)

 

 

Message 18 of 40

ronjonp
Advisor
Advisor

Here is another for fun. @h_s_walker How long have you been doing this manually?

 

(defun c:foo (/ _get)
  ;; RJP » 2024-10-10
  (defun _get (table / l r)
    (while (setq l (tblnext table (null l)))
      (or (wcmatch (strcase (cdr (assoc 2 l))) "`**,*|*,XCLIENT*")
	  (setq r (cons (cdr (assoc 2 l)) r))
      )
    )
    (acad_strlsort r)
  )
  (command "_.UNDO" "BEGIN")
  (setvar 'cmdecho 0)
  (foreach x '("BLOCK" "DIMSTYLE" "LAYER" "LTYPE" "STYLE")
    (foreach y (_get x)
      (vl-catch-all-apply 'vl-cmdf (list "_.RENAME" x y (strcat "XCLIENT-" y) ""))
    )
  )
  (setvar 'cmdecho 1)
  (command "_.UNDO" "END")
  (princ)
)

 

Another way to solve this sorting problem is to have a template and make all your layers blocks etc prefixed with '00-'. 

 

 

 

 

0 Likes
Message 19 of 40

ronjonp
Advisor
Advisor

@MrJSmith You should probably check that the name does not already contain the prefix otherwise it'll double\triple\quadruple up.

0 Likes
Message 20 of 40

MrJSmith
Advocate
Advocate

@ronjonp He wanted all the named objects as listed in the RENAME command. That only handles the tables. You still have to do the dictionaries. 

0 Likes