Jump to content

Recommended Posts

Posted

Anybody help me with a lisp will do so . . .

Notepad text should be change as shown . . .

 

Text                ("Text" "0")

Text1             ("Text1" "0")

Text2             ("Text2" "0")

Text3             ("Text3" "0")

Merge Layers.png

Posted

I have no clue as of what you want or need...

Posted

Text1     change to    ("Text1" "0")

Text2     change to    ("Text2" "0")

Text3     change to    ("Text3" "0")  at Notepad

Posted (edited)

Top is what your getting bottom is what you want?

 

(setq F1 (open "path to txt") "w"))  ;Create text file that you write to
(princ (strcat "Existing LT Pole " (sslength SS) "\n"  F1) ;if your counting with selection set
(princ (strcat "Existing LT Pole " (itoa i) "\n"  F1) ;if your counting with a variable

...  


(close F1)

 

Edited by mhupp
Posted

Something like this?

(defun c:demo (/ file file1 fname fname1 l)
  (if (and (setq fname (getfiled "Select the Text file" (getvar 'dwgprefix) "txt" 0))
	   (setq file (open fname "r"))
	   (setq fname1	(getfiled "New Text File" (strcat (substr fname 1 (- (strlen fname) 4)) "-NEW") "txt" 1))
	   (setq file1 (open fname1 "w"))
      )
    (progn
      (while (setq l (read-line file))
	(write-line (strcat "(\"" l "\" \"0\")") file1)
      )
      (close file)
      (close file1)
    )
  )
  (princ)
)

 

I hope this helps.

Henrique

  • Thanks 1
Posted (edited)

In Word can use ^p to replace end of line so can do 2 replaces one for (" and second " "0")^p  but must save as text file and Word can do funny stuff leaving hidden characters. When i do this copy and paste to notepad to make sure.

 

I use notepad++ and it appears to support \n as end of line but could not get sequence quite right will keep trying, I will try their forum etc.

 

image.png.c82b986ffddb07a41826b69a3c5e043e.png

 

If you want it as lisp code to make a list need '("tetxt1" "0")

Edited by BIGAL
  • Funny 1
Posted (edited)

Found it easy to do in Notepad++ you can prefix and suffix all lines, I am no expert but with a bit of practice would become super quick. Yes tried it out. PS its free.

 

Ok found on Notepad++ forum.

 

prefix go to left 1st character top line press Alt+Lmouse drag down this does a vertical column, just type what you want ("

suffix got to top line, last character again Alt+Lmouse drag down creates a vertical column, just type " "0")

 

All done.

Edited by BIGAL
Posted (edited)

That's amazing silva ! That worked beautifully. Thank you. I appreciate the help very much !

Thanks to BIGAL as well . . .
& I need little more from silva as below Image.

Merge 2 notepads & create new

 

Merge Layers1.jpg

Edited by Gentile Romano
Posted
5 hours ago, Gentile Romano said:

That's amazing silva ! That worked beautifully. Thank you. I appreciate the help very much !

Thanks to BIGAL as well . . .
& I need little more from silva as below Image.

Merge 2 notepads & create new

 

 

You're welcome, @Gentile Romano

A quick one, minimally tested...

(defun c:demo (/ file file1 file_n fname fname1 fname_n i l lst lst1 n)
  (if (and (setq fname (getfiled "Select the first Text file" (getvar 'dwgprefix) "txt" 0))
	   (setq file (open fname "r"))
	   (setq fname1 (getfiled "Select the second Text file" (getvar 'dwgprefix) "txt" 0))
	   (setq file1 (open fname1 "r"))
	   (setq fname_n (getfiled "New Text File" (strcat (substr fname 1 (- (strlen fname) 4)) "-NEW") "txt" 1))
	   (setq file_n (open fname_n "w"))
      )
    (progn
      (while (setq l (read-line file))
	(setq lst (cons (strcat "(\"" l "\" ") lst))
      )
      (close file)
      (setq lst (reverse lst))
      (while (setq l (read-line file1))
	(setq lst1 (cons (strcat "\"" l "\")") lst1))
      )
      (close file1)
      (setq lst1 (reverse lst1))
      (setq n 0)
      (if (= (setq i (length lst)) (length lst1))
	(progn
	  (while (< n i)
	    (write-line (strcat (nth n lst) (nth n lst1)) file_n)
	    (setq n (1+ n))
	  )
	  (close file_n)
	)
	(prompt "\nFiles do not have the same number of lines... ")
      )
      )
    )
  (princ)
)

 

Hope this helps,
Henrique

Posted

awesome !  😃

thanks silva

Posted
Just now, Gentile Romano said:

awesome !  😃

thanks silva

 

You're welcome, @Gentile Romano
Glad I could help

 

Henrique

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...