Jump to content

Recommended Posts

Posted

Hello all.

Believe it is possible a lisp routine to be able to make reading a table and insert the values ​​into specific blocks?

Electrical design projects, specifically for tractors whips. I use autoCAD 2010 (normal). The work is very repetitive.

We have a software that generates the electric list (From / To) however, the company where I work is unable to make any investment in "Routing Software". Unfortunately the work is all manual.

 

For example, the ID "1" in the attached table should appear on the connector Tagged POSITION "CON-01," Cavity "A" and the connector Tagged POSITION "CON-02," Cavity "P". So forth.

This can be possible?

Thank you.

Conector.dwg

Posted

Welcome to the forum and family. A good rule of thumb when longing for smart solutions to seemingly stupid and tedious tasks, is to invest a few minutes of your manually intensive and repetitive day, and visit an oasis for those who wish to work more intelligently. http://www.lee-mac.com/macatt.html the link provided may or may not be the best one for your question. Probably not, just a link I had on my desktop. Look through Lee's remarkable library, and see if there just might be an easier way to accomplish the task at hand. Good luck on your quest, and thanks again to LEE MAC! :beer:

Posted
Welcome to the forum and family. A good rule of thumb when longing for smart solutions to seemingly stupid and tedious tasks, is to invest a few minutes of your manually intensive and repetitive day, and visit an oasis for those who wish to work more intelligently. http://www.lee-mac.com/macatt.html the link provided may or may not be the best one for your question. Probably not, just a link I had on my desktop. Look through Lee's remarkable library, and see if there just might be an easier way to accomplish the task at hand. Good luck on your quest, and thanks again to LEE MAC! :beer:

 

Thank you for the answer Dadgad.

In fact Lee's programs are very interesting and inspire great ideas.

I quote from a program with him, I'm waiting for the answer.

I believe that some changes in the program below will meet my needs.

 

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

 

Thank again.

Posted

I don't know if this is what you were looking for, I'm in electrical also and use it quite frequently. Personally i hate user inputs and don't mind editing my lisp files, so forgive the no user input method. This routine is basically a find and replace.

 

(defun CHGTEXT (/ SS_edit SS_EditLenCnt SS_EditLen ent old_str as new_str st s new_strlen old_strlen sl si chg_fnd chg_made)
(setq SS_edit (ssget "X" (list (cons 0 "TEXT"))))
(setq chg_made 0)
(if SS_edit 
	(progn                    
		(setq old_strlen (strlen (setq old_str to_find)))	
		(setq new_strlen (strlen (setq new_str change_to)))	
		(setq SS_EditLenCnt 0 SS_EditLen (sslength SS_edit))
		(while (< SS_EditLenCnt SS_EditLen)                
			(if (= "TEXT"              
			(cdr (assoc 0 (setq ent (entget (ssname SS_edit SS_EditLenCnt))))))
				(progn
				(setq chg_fnd nil si 1)
				(setq s (cdr (setq as (assoc 1 ent))))
					(while (= old_strlen (setq sl (strlen
					(setq st (substr s si old_strlen)))))
						(if (= st old_str)
							(progn
								(setq s (strcat (substr s 1 (1- si)) new_str (substr s (+ si old_strlen))))
								(setq chg_fnd t)    
								(setq si (+ si new_strlen))
							);progn
							(setq si (+ 1 si))
						);if
					);while
					(if chg_fnd
						(progn
							(setq ent (subst (cons 1 s) as ent))
							(entmod ent)       
							(setq chg_made (+ 1 chg_made))
						);progn
					);if
				);progn
			);if
			(setq SS_EditLenCnt (+ 1 SS_EditLenCnt))
		);while
	);progn
);if
(princ "Changed ")
(princ chg_made)
(princ " text lines.")
);chgtext




(defun c:cgt (/ tofind changeto)

(setq Ol_Osmode (getvar "OSMODE"))
(setvar "OSMODE" 0)
(setvar "ATTREQ" 0)
(setvar "FILEDIA" 0)		

(setq to_find "[b][color="red"]TO FIND[/color][/b]" change_to "TO CHANGE TO")(chgtext)
		
(setvar "OSMODE" Ol_Osmode)
(setvar "ATTREQ" 1)
(setvar "FILEDIA" 1)
	
(COMMAND "REGEN")
(COMMAND "QSAVE")
;(COMMAND "CLOSE")

);cgt

Posted

Hello btraemoore, thank you very much for the reply.

Perhaps the intention is clear but still do not understand the language lisp.

Could you give me an example of using?

Thank you.

[text translated]:oops:

Posted

Yes can be done I have done something similar where you pick text or a block to identify another block and update its attributes. The blocks can live any where in the drawing.

 

Looking at dwg, Con-01 would need a hidden attribute ID_No so when you pick line 1 in table it finds block con_01 and updates the block line with the Id= 1 and like wise Con-o2 Id =1. You would need to create multiple blocks with the ID being increased by 1 each time added or copy/paste from another dwg.

 

The code works by searching for a block name list and for a specific attribute value and then update the block with some new details.

 

Its in VBA and has been posted a few times here I will try to find, as another answer there has been posts for examples of replacing attributes via there "tag" name as first step and some else may help with example of reading the table entries, then just put the two together.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...