Jump to content

Recommended Posts

  • Replies 59
  • Created
  • Last Reply

Top Posters In This Topic

  • Sambuddy

    23

  • rlx

    20

  • lrm

    9

  • BIGAL

    7

Top Posters In This Topic

Posted Images

Posted

I think I am messing up with the (-) negative as a start of my coordinates. By removing them and running the lisp now I am getting:

image.thumb.png.9c13342e85258bc69faebbeec59475f9.png

 

rlx? could this be the cause you think?

Posted

Compared variables and couldn't find significant differences. I runned my script in your drawing and it performed as suspected. Only (stupid / silly) way could be to run your script file thru a lisp. Don't expect it to make much difference but then , you've nothing to lose...


 

(defun c:t1 ( / fn fp cmd)
  (if (and (setq fn (getfiled "Select script" "" "scr" 0))(setq fp (open fn "r")))
    (while (setq cmd (read-line fp))(command cmd))) (if fp (close fp)) (princ))

 

(defun c:t2 ( / fn fp cmd cmd-list)
  (if (and (setq fn (getfiled "Select script" "" "scr" 0))(setq fp (open fn "r")))
    (while (setq cmd (read-line fp))(setq cmd-list (cons cmd cmd-list))))
  (if fp (close fp))(mapcar 'command (reverse cmd-list)) (princ))

 

 

both codes do the same , just tried two approaches but there are more like command-s ,  vl-cmdf and with error checking thr vl-catch-all-apply but think that would be overkill...

Posted

is there a way for your lisp to say:

run script 1, end

then run script 2, end

then ...

under one command, same directory?

Posted

one last time:

is it possible for a lisp to say: pline <enter>, then open content from c:/temp/DATA_1.scr or txt, then paste?

 

can it be done?

Posted

haven't tested it but maybe :

 


(defun c:t3 ( / fn fp cmd)
  (foreach fn (list "c:\\temp\\1.scr" "c:\\temp\\2.scr" "c:\\temp\\3.scr")
    (if (and (findfile fn)(setq fp (open fn "r")))
      (while (setq cmd (read-line fp))(command cmd)))
    (if fp (close fp))
  )
  (princ)
)

 

just change the filenames in the (list "c:\\temp".... to your own. You could play with excluding one of the script files to see if one of them is giving you trouble :danger:

Posted
13 minutes ago, Sambuddy said:

one last time:

is it possible for a lisp to say: pline <enter>, then open content from c:/temp/DATA_1.scr or txt, then paste?

 

can it be done?

 

yes this can also be done, not a bad idea 🤓 , code would only be a little different from my last code but if you don't mind ....😴 ... 2morrow you're numero uno 💤

Posted

Just replace the use a list with read a file.

 

; create pline from a list of points
; By Alan H March 2019

(defun AHpllst ( lst / x)
(command "_pline")
(while (= (getvar "cmdactive") 1 )
(repeat (setq x (length lst))
(command (nth (setq x (- x 1)) lst))
)
(command "")
)
)

 

Posted (edited)

damn , autocad licence server is down... so good luck with this :

(defun c:t4 ( / fn fp cmd cmd-list)
  (vl-load-com)
  (mapcar '(lambda (x)(setvar (car x) (cadr x))) '(("limcheck" 0)("texteval" 1)("osmode" 0)))
  (foreach fn (list "c:/temp/data1.txt" "c:/temp/data2.txt" "c:/temp/data3.txt" "c:/temp/data4.txt" "c:/temp/data5.txt")
    (if (and (findfile fn)(setq fp (open fn "r")))
      (progn (prompt (strcat "\n\nProcessing data from : " fn))
        ;(while (setq cmd (read-line fp))(setq cmd-list (cons cmd cmd-list)))
        (while (setq cmd (read-line fp))(setq cmd-list (cons (vl-string-trim " " cmd) cmd-list)))
        (if (vl-catch-all-error-p (setq err (vl-catch-all-apply 'vl-cmdf (cons "._pline" (reverse cmd-list)))))
          (prompt (strcat "\n\n* * * error executing script from " fn)))
        (prompt (strcat "\n\nEnding pline command from data file " fn))
        (while (= 1 (logand (getvar "cmdactive") 1))(command ""))
        (if fp (close fp))(setq cmd-list '())
      )
    )
  )
  (vla-ZoomExtents (vlax-get-acad-object))
  (princ "\n\nProcessing data files completed")
  (princ)
)

data1.txt data2.txt data3.txt data4.txt data5.txt

Edited by rlx
autocad server is back online...
Posted

rlx,

You have outdone yourself once more!

I thank you for all your time and effort in producing this lisp (t4). However simple it may look to you, it is amazing how you can write your codes with little to no information I have given you and then your magic of coding happens!

 

Thank you again

giphy.gif 

Posted

ah, you make me blush...

 

 

 

1593279092_verlegendraak.png.cabf65b442a7716bffeab55321bd298c.png

 

Hope I still can sit tonight with so many feathers up my... 😄

 

 

🐉

Posted

Thanks man! I sincerely appreciate your work!

Posted

Hey rlx,

Your LISP (T4) does magic - the userform I created in excel is all plines for the first form as below and the result is just gorgeous:

image.png.782490ce87ea964eb690995be3dc58b4.pngimage.thumb.png.30776ac2625739c98ba5b1462c211d97.png

 

now that I am doing for second userform in excel, I am facing with another problem. Below is the form:

 

image.thumb.png.c99fc59c2e38a2cf763d4872cfd61ea3.png

 

As it happens I have some circle to draw - is there a way for your second LISP (say T5) to draw that up for me? My txt files are unique for every application - so for example my txt files for these three circles are data121.txt, data122.txt and data 123.txt. Could this exception be incorporated into the LISP?

I especially likes not to use pline and close in every frickin coordinate on your previous LISP.

Thanks rlx again

Posted

I suppose by getting all text files in a dedicated folder and by looking at their names you would be able to say 1-99 is pline , 100-200 is circle etc.

Posted (edited)

Does not make sense to me just add correct command as the 1st line like Pline, Line, Circle, Arc only need 1 program as always write the same file name. Spend the extra 5 minutes writing the scr file correct.

 

See the post page 2 by LRM draws multiple plines in one go.

Edited by BIGAL
Posted

Guess it makes perfectly sense to anyone comfortable with vba and not (yet) with lisp 😟. Also OP said he had trouble with running script directly from vba but it worked when pasted to Autocad. Thats why I read the script itself and pass the input to autocad command even though its a bit like phoning one of the kids to come over and to pass on the salt or suger from me to their mother. But hey , if it works.... We have all been there , in despair over how lisp processes names & values.

Posted

Rlx If you look at your own post data 1.txt only needs Pline as 1st line and save as a script  learning how scripts work is not that hard, for Sambuddy get a pencil and paper and write down all the steps all the enters etc when drawing an object. It dos not make sense to me to write a program to run multiple scripts rather than "BUILD" a dwg. Excel step 1, Autocad XXX, Excel step2 Autocad xxx,  not very hard.

 

If you want a mega script, then use the "A" option in file handling which is append to a file in your excel VBA.

 

(defun c:xxxx ( / ) 
(command "script" "c:\\myfiles\\somejunk\\tower.scr")
)

 

Posted (edited)

He already tried that , at least that's what I understood , without succes. I still dont understand why splitting up the script works and one big srcipt doesn't. But for now it is what it is. Maybe if you could sit next to his computer and looking over his shoulder you could see what's going on but we can't.

 

Inspired by his other post on the excel sheet with hyperlinks I'm writing a routine that can hyperlink a folder / mapped network folder and place all the subfolders as a hyperlink in a worksheet. I think I'm going to call it pup (pretty useless program) because windowskey+E and ctrl-F or something like that will get you there too but just for fun. Have a project folder at work with allmost 800 folder with a projectnumber in them. Getting the right one isn't really that hard but to get explorer open up in the right folder by typing just the project number could save me a few second a day 😄

 

well on this side of the planet its getting late  ... 💤

Edited by rlx
  • 3 weeks later...
Posted

Special thanks to rlx for your LISP - I just posted a message on the tower profile post. I just finished completing the excel portion and with your elegant LISP I can now bring all my data right into cad so...

giphy.gif Thanks rlx

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