Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Autocad lisp for copying object and making them to a particular color

18 REPLIES 18
SOLVED
Reply
Message 1 of 19
bireshwar.mallick
4666 Views, 18 Replies

Autocad lisp for copying object and making them to a particular color

It will be highly beneficial for a quality control work if a lisp is designed in which after copying AutoCAD objects and pasting results to a specific color.

This will show that how many number of objects have been edited in a shop drawing.

Bireshwar
18 REPLIES 18
Message 2 of 19
hmsilva
in reply to: bireshwar.mallick

Hi Bireshwar,

is required more explanation on "copying AutoCAD objects and pasting results to a specific color"

Copy/paste?

Are you going to use the command between dwg's?

Wouldn't be sufficient the copy command?

What type of entities you intend to copy, simple objects such as lines, arcs, polylines,.. or more complex objects such as blocks, inserts...?

 

If possible, attach a sample dwg exemplifying what you intend to do.

 

Henrique

EESignature

Message 3 of 19
bireshwar.mallick
in reply to: hmsilva

Dear Henrique,

We only require to copy text in the same drawing and after copying only the color of the dtext/mtext changes to a particular color say for example red.

For better review we are hereby attching a snap for the same.

Best Regards,

Bireshwar

Bireshwar
Message 4 of 19
hmsilva
in reply to: bireshwar.mallick

Quick and dirty...

(defun c:test ( / ENT S SS)
  (setq ss (ssadd)
	ent (entlast))
(if (setq s (ssget "_:L" '((0 . "*TEXT"))))
  (progn
    (command "_.copy" s "" pause pause)
  (while (setq ent (entnext ent))
    (ssadd ent ss)
  )
    (if ss
      (command "_.chprop" ss "" "_C" "1" "")
      )
    )
  )
  (princ)
  )

HTH

Henrique

EESignature

Message 5 of 19
bireshwar.mallick
in reply to: hmsilva

Thanks a lot for the resolution. Will it be feasible if the red colored text will return to by layer after it has been edited.
Bireshwar
Message 6 of 19
hmsilva
in reply to: bireshwar.mallick


@bireshwar.mallick wrote:
Thanks a lot for the resolution. Will it be feasible if the red colored text will return to by layer after it has been edited.

You're welcome, Bireshwar

 

As a "demo"

 

(defun c:test ( / ENT HND STR)
  (if (setq hnd (car (entsel "\nSelect an annotation object: ")))
    (progn
      (setq ent (entget hnd))
      (setq str (cdr (assoc 1 ent)))
      (command "_.ddedit" hnd)
      (while (> (getvar 'cmdactive) 0)
	(command pause)
	)
      (if (not (wcmatch (cdr (assoc 1 (entget hnd))) str))
	(command "_.chprop" hnd "" "_C" "bylayer" "")
	)
      )
    )
  (princ)
  )

HTH

Henrique

EESignature

Message 7 of 19
bireshwar.mallick
in reply to: hmsilva

Dear Henrique,

Good day and really a nice routine get a good customization. If a small objective is to be noted :

1. Edited text after pressing an enter seems correct and gets back to by layer.

2. Edited text without pressing an enter retains the RED color.

I am hereby attaching a snap for your reference.

Bireshwar
Message 8 of 19
hmsilva
in reply to: bireshwar.mallick


@bireshwar.mallick wrote:

Dear Henrique,

Good day and really a nice routine get a good customization. If a small objective is to be noted :

1. Edited text after pressing an enter seems correct and gets back to by layer.

2. Edited text without pressing an enter retains the RED color.

I am hereby attaching a snap for your reference.


Bireshwar,

I can't reproduce that behavior, because to exit the editing inside the command "Test", you'll have to press the space bar or the enter, if you press the esc. will cancel the command...

 

Henrique

 

EESignature

Message 9 of 19
bireshwar.mallick
in reply to: hmsilva

Hi Henrique,

Thanks for the update and yes its a valuable customization. Can we copy the text and the leader (as its a part of annotaion) to a red color instead of the text which will really make the tool very useful for quality check. I really missed out that we require text with leader copy to other areas of files.

Best Regards,

 

Bireshwar
Message 10 of 19
hmsilva
in reply to: bireshwar.mallick


@bireshwar.mallick wrote:

Hi Henrique,

Thanks for the update and yes its a valuable customization. Can we copy the text and the leader (as its a part of annotaion) to a red color instead of the text which will really make the tool very useful for quality check. I really missed out that we require text with leader copy to other areas of files.

Best Regards,

 


Attach a sample dwg (not img) exemplifying what you are trying toaccomplish.

 

Henrique

EESignature

Message 11 of 19
bireshwar.mallick
in reply to: hmsilva

Dear Henrique,

I have attached a sample dwg that illustrates why we are requiring this feature that may be helpful for quality checking any AutoCAD shop drawing either in MEP section or Architectural, Structural and Concrete. My points for validating this feature is stated underneath :

1. We have a common practice of copying similar text with leader (generally present in the same layer) rather than writing the same again as there may be 100's of text and annotations.

2. Many a times we forget to edit the copied text.

3. For piping generally parameters like BOP(Bottom of pipes), dia and other similar parameters are required for copying.

4. For ducting parameters like BOD (Bottom of duct) and various other parameters are required to be copies.

5. For Architectural,Structural similar parameters like elevation,wall thickness and many more others needs to be copies rather than texting the same.

 

For all the validations we generally require the leader to be copied as well as its the part of annotation (text+leader). Hope I have made the practical objectives clear that may be helpful for any CAD working domain.

Have a good day !!

Best Regards,

Bireshwar

 

 

Bireshwar
Message 12 of 19
503800335
in reply to: hmsilva

mark

Message 13 of 19
hmsilva
in reply to: bireshwar.mallick

Bireshwar.
just remember that, to the text color return to bylayer, you'll need to use the MyE routine, if you use juste the AutoCAD "ddedit" the color will not be changed...

 

(defun c:MyC ( / ENT S SS);; My Copy
  (setq ss (ssadd)
	ent (entlast))
  (prompt "\nSelect Leader and Annotation to copy: ")
(if (setq s (ssget "_:L" '((0 . "*TEXT,LEADER"))))
  (progn
    (command "_.copy" s "" pause pause)
  (while (setq ent (entnext ent))
    (if (wcmatch (cdr (assoc 0 (entget ent))) "*TEXT")
    (ssadd ent ss)
      )
  )
    (if ss
      (command "_.chprop" ss "" "_C" "1" "")
      )
    )
  )
  (princ)
  );; MyCopy

(defun c:MyE ( / ENT HND STR);; My Edit
  (if (setq hnd (car (entsel "\nSelect an annotation object: ")))
    (progn
      (setq ent (entget hnd))
      (setq str (cdr (assoc 1 ent)))
      (command "_.ddedit" hnd)
      (while (> (getvar 'cmdactive) 0)
	(command pause)
	)
      (if (not (wcmatch (cdr (assoc 1 (entget hnd))) str))
	(command "_.chprop" hnd "" "_C" "bylayer" "")
	)
      )
    )
  (princ)
  );; MyEdit

 

HTH

Henrique

EESignature

Message 14 of 19
bireshwar.mallick
in reply to: hmsilva

Dear Henrique,

Thanks a ton!! The routine served the workflow requirements. Henrique can you guide us with some good ebooks on Autolisp so that I can grab the topic well. Professionally I am a Java developer (web and desktop application) and have a bit of knowledge in the Autolisping. Please do suggest the IDE for carrying our healthy autolisping for example I ues Eclipse, Oracle JDeveloper and Netbeans IDE for carrying out Java developments. It will be of a major help.

Have a great day ahead 🙂

 

Bireshwar
Message 16 of 19
hmsilva
in reply to: bireshwar.mallick

And for an IDE

 

personally, I use the Autodesk VLIDE, for AutoLISP and Visual LISP, and it is pretty good.

 

Take a look at this Lee Mac tutorial

http://www.lee-mac.com/introtovlide.html

 

 

HTH

Henrique

EESignature

Message 17 of 19
bireshwar.mallick
in reply to: hmsilva

Thanks a lot for the suggestion.
Bireshwar
Message 18 of 19
hmsilva
in reply to: bireshwar.mallick

You're welcome, Bireshwar

Henrique

EESignature

Message 19 of 19
bireshwar.mallick
in reply to: hmsilva

Thanks a lot for the valued suggestion. We again have a routine that needs to be programmed under the following mentioned link :-
"http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/AutoCAD-tool-required-for-selecting-d...
Can you please put a thought onto it.
Best Regards,
Bireshwar
Bireshwar

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

Post to forums  

Autodesk Design & Make Report

”Boost