Jump to content

Auto lisp program to dxf out multiple sections of a drawing.


dthoren

Recommended Posts

Ok i am very new to writting lisp programs. Started writing on today and it doesnt do anything for me. What i need it to do is select areas on a drawing and then dxf those parts under the name serialnumber_fmvss.dxf, serialnumber_cmtv.... etc.

 

Not sure what im missing but this is the code i have already

Edited by SLW210
Clean up
Link to comment
Share on other sites

(defun c:platedxf ()
(setq fileprefix (getstring "Enter serial number: "))
(setq fmvss (strcat fileprefix "_fmvss.dxf"))
(setq cmtv (strcat fileprefix "_cmtv.dxf"))
(setq ct1 (strcat fileprefix "_ct1.dxf"))
(setq ct2 (strcat fileprefix "_ct2.dxf"))
(setq ct3 (strcat fileprefix "_ct3.dxf"))
(setq ct4 (strcat fileprefix "_ct4.dxf"))
(setq ct5 (strcat fileprefix "_ct5.dxf"))
(setq pt1 '(17.6960 4.5 0))
(setq pt2 '(23.6960 0 0))
(setq pt3 '(17.6960 -0.5 0))
(setq pt4 '(25.5082 -4 0))
(setq pt5 '(17.6960 -4.5 0))
(setq pt6 '(23.6959 -9 0))
(setq pt7 '(17.6960 -9.5 0))
(setq pt8 '(23.6959 -14 0) )
(setq pt9 '(17.6960 -14.5 0))
(setq pt10 '(23.695 9 -19 0))
(setq pt11 '(17.6960 -19.5 0))
(setq pt12 '(23.6959 -24 0))
(setq pt13 '(17.6960 -24.5 0))
(setq pt14 '(23.6959 -29 0))

(setq ss1 (ssget "w" pt1 pt2))
(setq ss2 (ssget "w" pt3 pt4))
(setq ss3 (ssget "w" pt5 pt6))
(setq ss4 (ssget "w" pt7 pt)
(setq ss5 (ssget "w" pt9 pt10))
(setq ss6 (ssget "w" pt11 pt12))
(setq ss7 (ssget "w" pt13 pt14))

(command "_.dxfout" fmvss "" "_O" ss1 "" "")
(command "_.dxfout" cmtv "" "_O" ss2 "" "")
(command "_.dxfout" ct1 "" "_O" ss3 "" "")
(command "_.dxfout" ct2 "" "_O" ss4 "" "")
(command "_.dxfout" ct3 "" "_O" ss5 "" "")
(command "_.dxfout" ct4 "" "_O" ss6 "" "")
(command "_.dxfout" ct5 "" "_O" ss7 "" "")



(princ)
)

Link to comment
Share on other sites

I would take a diffrent approach to your coding method and use a list of the parameters and then just use a repeat to go through the list you can have as many as you like then. Note also only 1 ss1 is required as you remake it each time within the repeat.

 

Will try to post tomorrow if some one else does not do an example 1st.

 

(command "_.dxfout" Fname "V" "2000" "_O" ss1 "" "")
; the list
((Fmvss pt1 pt2)(cmtv pt1 pt2)(........))

Link to comment
Share on other sites

If your happy why not

 

pick pt1, pick pt2 dxfout Fmvss

pick pt1 pt2 dxfout Cmvt

pick pt1 pt2 dxfout cnt1 but this repeats till you say stop picking, next is cnt2 auto incrementing as many times as required. Picking points and writing code does not make a lot of sense unless every dwg is identical, a fraction accident move and the code does not work.

 

dthoren please clarify fixed or as required.

Link to comment
Share on other sites

Ya I'm aware that normally it's better to pick points but this is one of those times that I can actually get away with static points the autocad file this would be used on is for a data plate basically. What's happening before this program is that autocad is pulling information from an excel file which is placed in tables on the plates. Basically the only reason we are using autocad is to create the dog files for an engraving machine. So not in anyway a typical autocad file.

Link to comment
Share on other sites

Realized I didnt explain that as good as i should have. So the autocad file is a write protected file, well will be when im done making it. These 7 dataplates will never move in the window. Basically the user opens the dwg file and an excel file. Sets the excel file to process an specific serial number then the user would tell the autocad file to update links then tables are exploded and text that is remaining is dxf'ed for use in an engraving machine.

Link to comment
Share on other sites

You may be better doing the coding in excel copy and paste to command line, if you have the co-ords there then its easy. You would just write the dxfout lines into a column using concatenate to make the _.dxfout Fname V 2000 _O (setq ss1 (ssget "w" (list x y) (list x y)))

 

Can you post the excel ? It is possible to read excel directly so no need for a lisp for every excel you want.

Link to comment
Share on other sites

anyway you could do up a little sample of something like this. From Excel. I would include my files but I think most of the links would get broken being linked to other databases and what not. I feel i could figure it out with just a little stearing.

Link to comment
Share on other sites

Can i see an example of how htis would be typed with the user selecting everytime

 

I would take a diffrent approach to your coding method and use a list of the parameters and then just use a repeat to go through the list you can have as many as you like then. Note also only 1 ss1 is required as you remake it each time within the repeat.

 

Will try to post tomorrow if some one else does not do an example 1st.

 

(command "_.dxfout" Fname "V" "2000" "_O" ss1 "" "")
; the list
((Fmvss pt1 pt2)(cmtv pt1 pt2)(........))

Link to comment
Share on other sites

Different tact get excel to do a csv file

 

Name,x1,y1,x2,y2

 

Use a WHILE to Read the csv file 1 line at a time use parse-csv to a list

 

(fname x1 y2 x2 y2)

You can then pull it part and do the ssget using x1,y1 x2,y2

(command "_.dxfout" (nth 0 lst) "V" "2000" "_O" ss1 "" "")

till end of csv

 

let me know if thats the way you would like to go.

 

Others may jump in sooner need to do some real work.

Link to comment
Share on other sites

I actually got my dxf out function to work all i was missing was the file directory. c:// etc.. and it works well for what we need but thank you all for your help. Im sure ill be back to this forum. Learned a lot just by searching other posts.

Link to comment
Share on other sites

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