Jump to content

I would like to turn this LISP function into a DCL / LISP function any help !


Recommended Posts

Posted (edited)

Well here goes, this is my first post and I am hoping for great results as I have seen from other posts. I am working on converting a set of LISP routines that I have developed other the years to DCL page prompts instead of command prompt input. I am by no means a programmer and some (all) of my routines are not any where near as condensed as they could (should) be however they all work. Any suggestions / comments would be appreciated as I make no bones about my programming (or lack thereof) skills.

 

 

Code Deleted see next post....

 

 

 

Thanks,

Bruce

Edited by Snownut
Removed code and reposted properly below
Posted

Sorry Lee Mac, let me try this again.

 

(defun C:SLine ()
 (setvar "osmode" 163)
 (setq lwght(getvar "celweight"))
 (setq svLayer (getvar "clayer"))
 (command "layer" "s" "site" "")
 (setvar "TEXTEVAL" 1)
 (setq slt 0)
 (setq answ nil)
 (while (or (< SLT 1) (> SLT 3))
   (setq SLT(Getint "\nSewerline Type: 1=House-Tank...2=Tank-Bed/D-Box...3=Tank-Tank..? "))
   )
 (if (= slt 1)
   (setq hTot 0)
   )
 (if (= slt 2)
   (setq tTod 0)
   )
 (if (= slt 3)
   (setq tTot 0)
   )
 (setq pt1a (getpoint "\nStarting Point: "))
 (setq xpt1 (car pt1a))
 (setq ypt1 (cadr pt1a))
 (setq pt1 (list xpt1 ypt1))
 (setq ct 0)
 (while (< ct 2)
   (prompt "\nNext Point: ")
   (setvar "celweight" 25)
   (command "LINE" pt1 pause "")
   (setq pt2a(getvar "lastpoint"))
   (setq xpt2 (car pt2a))
   (setq ypt2 (cadr pt2a))
   (setq pt2 (list xpt2 ypt2))
   (setq dis (rtos (distance pt1 pt2)))
   (setvar "celweight" lwght)
   (setvar "osmode" 0)
   (command "TEXT" "s" "simplex" pt1 pt2 (strcat dis"'" ))
   (prompt "\nText Location: ")
   (command "MOVE" "L" "" pt1 pause)
   (setq pt1 pt2)
   (setq answ(getstring "\nAny Key to END or ENTER to <continue> ?  "))
   (if (= slt 1)
     (setq HtoT (+ HtoT (atof dis)))
     )
   (if (= slt 2)
     (setq TtoD (+ TtoD (atof dis)))
     )
   (if (= slt 3)
     (setq TtoT (+ TtoT (atof dis)))
     )
   (if (= answ "")
     (setq ct 0)
     (setq ct 2)
     )
   )
 (setvar "TEXTEVAL" 0)
 (setvar "clayer" svLayer)
 (setvar "osmode" 163)
 (princ          "\n  -  Utility Complete   -")
 (princ          "\n  - Hit Enter to Repeat -")
 (princ)
 )

 

I hope that's better.

Posted

Not sure what you meen by DCL page prompts the code is pretty simple adding dialouge prompts will probably slow it down.

 

Just a suggestion (command "LINE" pt1 pause "") replace with (setq pt2a (getpoint pt1a "\npick next point)) this will draw a line but it will disappear if you dont need it, a simpler way of implying two connected points if you do then (command "Line" pt1a pt2a "" ) Lee will tell you to use entmake for the line.

Posted (edited)
  Snownut said:
Well here goes, this is my first post and I am hoping for great results as I have seen from other posts. I am working on converting a set of LISP routines that I have developed other the years to DCL page prompts instead of command prompt input. I am by no means a programmer and some (all) of my routines are not any where near as condensed as they could (should) be however they all work. Any suggestions / comments would be appreciated as I make no bones about my programming (or lack thereof) skills.

 

 

Code Deleted see next post....

 

 

 

Thanks,

Bruce

 

Bruce,

 

Aside from the DCL for the moment, What is this code suppose to do? I added the SITE layer and Simplex font so the code would not error, Then it makes a line with the word MOVE above it. I saw the variable (dis) which is converted to a string and is a distance which I think is suppose to be the the text your are looking for, But this does not seem to be working. You also have coding in there that is really doing nothing.

 

Could you possibly post a drawing with the correct end result?

Edited by The Buzzard
Posted

Bruce,

 

I made a small Dialog as seen in the image below, I have also rewritten the code in entmake base on my assumptions. For now here is the image of the Dialog. I have also added a Text Scaling Option. The code works well now base on my assumptions, But I am not sure if the way I have now is the way you intended it to work. Once I can get confirmation on what this code is suppose to do, I shall post it. I still have some questions on it.

Document1.JPG

Posted

Its a very simple utility to draw a line of as many segments as the user chooses, and writes the distance of each line on the line. It then total the line distances and saves the variable (total distance), there are three variable possibilities so that each can be used later individually to calculate an elevation. The write to a file portion is not there, I have no issue with doing that part. These lines are actually representative of sewer line sections, 1st one from House to Septic Tank, next one from Septic Tank to Septic Tank for two tank systems, and the final one from Septic Tank to Septic system/D-Box.

 

I should have mentioned that this needs to be in x and y coordinates only even if the line is snapped to an object with a Z coordinate. Since for layout purposes all measurements are based on a level cordinate system. I am trying to get away completely from screen prompts and have all utilities run from Dialog Boxes.

 

I have more utilities that require calculations to be made while in the Dialog Box, no commands need to be executed just calculations.

 

I thank you all very much for your input and assistance.

 

Have a GREAT TURKEY Day.

Posted
  Snownut said:
Its a very simple utility to draw a line of as many segments as the user chooses, and writes the distance of each line on the line. It then total the line distances and saves the variable (total distance), there are three variable possibilities so that each can be used later individually to calculate an elevation. The write to a file portion is not there, I have no issue with doing that part. These lines are actually representative of sewer line sections, 1st one from House to Septic Tank, next one from Septic Tank to Septic Tank for two tank systems, and the final one from Septic Tank to Septic system/D-Box.

 

I should have mentioned that this needs to be in x and y coordinates only even if the line is snapped to an object with a Z coordinate. Since for layout purposes all measurements are based on a level cordinate system. I am trying to get away completely from screen prompts and have all utilities run from Dialog Boxes.

 

I have more utilities that require calculations to be made while in the Dialog Box, no commands need to be executed just calculations.

 

I thank you all very much for your input and assistance.

 

Have a GREAT TURKEY Day.

 

Ok,

 

But there is no difference in the following if statements, The all set to zero. Why bother using if?

Its not putting distance over the line, It is putting the word MOVE over the line.

So you are saying this code is incomplete? Maybe you should complete the code before bothering with the DCL.

 (if (= slt 1)
   (setq hTot 0)
   )
 (if (= slt 2)
   (setq tTod 0)
   )
 (if (= slt 3)
   (setq tTot 0)
   )

Posted

I don't want to set them all to 0 because the other two variables may have a value set in the variable already, however if this is being run for say the second or successive time I want to clear the variable that the user is redoing. At the begining of the utility I will put a read from or create file function and at the end i will put a write to file function. The process of designing the system involves moving things around possibly several times, and once the plan is complete it needs to be constructed. At that point if it is not constructed per plan the plan needs to be revised yet again to reflect the system as built. With this in mind i need to save these variables and be able to recall at a later time, up to 4 years later, as the plans are good for 4-years once approved. (and possibly longer if extensions are granted).

 

 

I would rather not post my DATA file (txt) information as it contains approx. 50 variables that I have saved in the Design process of the Septic Systems.

Posted
  Snownut said:
I don't want to set them all to 0 because the other two variables may have a value set in the variable already, however if this is being run for say the second or successive time I want to clear the variable that the user is redoing. At the begining of the utility I will put a read from or create file function and at the end i will put a write to file function. The process of designing the system involves moving things around possibly several times, and once the plan is complete it needs to be constructed. At that point if it is not constructed per plan the plan needs to be revised yet again to reflect the system as built. With this in mind i need to save these variables and be able to recall at a later time, up to 4 years later, as the plans are good for 4-years once approved. (and possibly longer if extensions are granted).

 

You are losing me here. The totals are all set to zero in your code and adding zero to the distance at the end of the code. So they are really at this point doing nothing. Also the three different Tank selections then are all going to be the same. If this is only because the code is incomplete, Then it may be best to see a completed code before making a DCL is all I am saying. Just to mention there is no error trapping in this code. The code also does not check for the presence of the layer or font style. You are saving user settings and restoring at the programs end, But if the program has errors or you hit escape in mid-command you will lose those saved settings.

 

I am not trying to be over the top here, But this code thats posted needs some work.

Posted

I appreciate your comments let me explain a little here, When the user initiates the design routine, all layers, line-types and other defaults are set. This needs to be done in order for any of the utilities to function properly. I have over 30 different functions with this one being the smallest of them all. There are several that print out over 5 pages long. All of the smaller ones (children I'll call them) are loaded in one big lisp file and then called individually as needed, this large LISP file (mother I'll call it) contains 16 different children. They all will be run eventually in the design process for each system designed. All of these children are called by a pull down menu system that I have developed. The purpose of this entire system is to assist in the designing of Septic Systems. I have lisp for designing 8 different system types currently and each of these has a couple of different configurations possible.

 

I do not have a lot of error trapping (none) in the codes at this time, I have been concentrating on just developing the code to complete each specific task, there are a lot of variables to take into account to ensure that the output meets STATE regulations and is flexible enough to meet all encountered conditions. I thank you for your input here and appreciate any advise you may have. As I have stated I am not a programmer by any other means then what I have pieced together developing this code. I have however designed close to 1,000 septic systems and have a fairly intricate knowledge of what it takes to do so, and the sequence that should be followed to do so in the most efficient manner. I know my code writing is not very efficient and can be rather convoluted, however I have managed to make it work. It has taken countless hrs, since I started this whole endeavor in 1990.

 

 

Cheers

Posted (edited)
  Snownut said:
I appreciate your comments let me explain a little here, When the user initiates the design routine, all layers, line-types and other defaults are set. This needs to be done in order for any of the utilities to function properly. I have over 30 different functions with this one being the smallest of them all. There are several that print out over 5 pages long. All of the smaller ones (children I'll call them) are loaded in one big lisp file and then called individually as needed, this large LISP file (mother I'll call it) contains 16 different children. They all will be run eventually in the design process for each system designed. All of these children are called by a pull down menu system that I have developed. The purpose of this entire system is to assist in the designing of Septic Systems. I have lisp for designing 8 different system types currently and each of these has a couple of different configurations possible.

 

I do not have a lot of error trapping (none) in the codes at this time, I have been concentrating on just developing the code to complete each specific task, there are a lot of variables to take into account to ensure that the output meets STATE regulations and is flexible enough to meet all encountered conditions. I thank you for your input here and appreciate any advise you may have. As I have stated I am not a programmer by any other means then what I have pieced together developing this code. I have however designed close to 1,000 septic systems and have a fairly intricate knowledge of what it takes to do so, and the sequence that should be followed to do so in the most efficient manner. I know my code writing is not very efficient and can be rather convoluted, however I have managed to make it work. It has taken countless hrs, since I started this whole endeavor in 1990.

 

 

Cheers

 

 

Wow! Since 1990?

 

Look I am only trying to find out what type of output you should have.

This is what I get after I put in the layer and font style, Then run the program:

[ATTACH]24794[/ATTACH]

 

Seems to me something is wrong here, So it is difficult to help unless we know what direction we are going.

From what you have told me, I should be expecting different output. Please understand why I am asking all these questions.

Document1.jpg

Edited by The Buzzard

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