Jump to content
Manila Wolf

Command line prompt not showing

Recommended Posts

Manila Wolf

Firstly to be clear I am a lisp novice.

 

I am building the following lisp which is a modification of an existing lisp.
It draws the inside and outside fillet radius of an angled sheet based on the thickness of the sheet.

 

My problem is that the command line prompts: -  "Select inside lines" and "Select outside lines" are not appearing in the command line window as desired.

I suspect I need to set the CMDECHO variable to 0 and the set it back to the original value (Usually 1).
I have seen this scenario in many lisps. However I don't know where to place the lines of code to set the CMDECHO to 1 and then set it back to the old CMDECHO value.
I have tried some trial and error scenario's (don't laugh), but I can't solve it.
Another thing that I think may come in to play is that an error trap may be needed.

 

I would be grateful for any help.

 

;By MarkD a modified version of the following: - 
;an AutoLISP routine that changes the fillet radius to accomodate the inside and outside radii of formed sheet metal pieces.
;Cadalyst Tip1379.LSP:  FLT.LSP   Dual Fillets   (C)1997, Robert Dieckmann
;https://cadtips.cadalyst.com/2d-operations/dual-fillets

 (defun
     C:AMCF ()
  (setq ITEM
         (strcase
           (getstring
             "\nType one of the following relevant wall thicknesses...  <1>  <1.5>  "
           ) ;_ end of getstring
         ) ;_ end of strcase
  ) ;_ end of setq
  (cond ((= "1" ITEM) (FLT1))
        ((= "1.5" ITEM) (FLT15))
  ) ;_ end of cond
) ;_ end of defun

(defun
     FLT1 (/ IRD THK ORD ITEM2)
  (setq ITEM2
         (strcase
           (getstring
             "\nType I or M to set appropriate units...   <I> for Imperial  or  <M> for Metric  "
           ) ;_ end of getstring
         ) ;_ end of strcase
  ) ;_ end of setq
  (cond ((= "I" ITEM2) (setq IRD 0.019685039)(setq THK 0.039370078))
        ((= "M" ITEM2) (setq IRD 0.5)(setq THK 1))
  ) ;_ end of cond
  (while (setq ORD (+ IRD THK))
  (command "_.fillet" "_r" IRD)
  (princ "\nSelect inside lines")
  (command "_.fillet" PAUSE PAUSE)
  (command "_.fillet" "_r" ORD)
  (princ "\nSelect outside lines")
  (command "_.fillet" PAUSE PAUSE)
)
  (princ)
) ;_ end of defun

(defun
     FLT15 (/ IRD THK ORD ITEM2)
  (setq ITEM2
         (strcase
           (getstring
             "\nType I or M to set appropriate units...   <I> for Imperial  or  <M> for Metric  "
           ) ;_ end of getstring
         ) ;_ end of strcase
  ) ;_ end of setq
  (cond ((= "I" ITEM2) (setq IRD 0.047244094)(setq THK 0.059055118))
        ((= "M" ITEM2) (setq IRD 1.2)(setq THK 1.5))
  ) ;_ end of cond
  (while (setq ORD (+ IRD THK))
  (command "_.fillet" "_r" IRD)
  (princ "\nSelect inside lines")
  (command "_.fillet" PAUSE PAUSE)
  (command "_.fillet" "_r" ORD)
  (princ "\nSelect outside lines")
  (command "_.fillet" PAUSE PAUSE)
)
  (princ)
) ;_ end of defun

 

Share this post


Link to post
Share on other sites
devitg
7 hours ago, Manila Wolf said:

Firstly to be clear I am a lisp novice.

 

I am building the following lisp which is a modification of an existing lisp.
It draws the inside and outside fillet radius of an angled sheet based on the thickness of the sheet.

 

My problem is that the command line prompts: -  "Select inside lines" and "Select outside lines" are not appearing in the command line window as desired.

I suspect I need to set the CMDECHO variable to 0 and the set it back to the original value (Usually 1).
I have seen this scenario in many lisps. However I don't know where to place the lines of code to set the CMDECHO to 1 and then set it back to the old CMDECHO value.
I have tried some trial and error scenario's (don't laugh), but I can't solve it.
Another thing that I think may come in to play is that an error trap may be needed.

 

I would be grateful for any help.

 


;By MarkD a modified version of the following: - 
;an AutoLISP routine that changes the fillet radius to accomodate the inside and outside radii of formed sheet metal pieces.
;Cadalyst Tip1379.LSP:  FLT.LSP   Dual Fillets   (C)1997, Robert Dieckmann
;https://cadtips.cadalyst.com/2d-operations/dual-fillets

 (defun
     C:AMCF ()
  (setq ITEM
         (strcase
           (getstring
             "\nType one of the following relevant wall thicknesses...  <1>  <1.5>  "
           ) ;_ end of getstring
         ) ;_ end of strcase
  ) ;_ end of setq
  (cond ((= "1" ITEM) (FLT1))
        ((= "1.5" ITEM) (FLT15))
  ) ;_ end of cond
) ;_ end of defun

(defun
     FLT1 (/ IRD THK ORD ITEM2)
  (setq ITEM2
         (strcase
           (getstring
             "\nType I or M to set appropriate units...   <I> for Imperial  or  <M> for Metric  "
           ) ;_ end of getstring
         ) ;_ end of strcase
  ) ;_ end of setq
  (cond ((= "I" ITEM2) (setq IRD 0.019685039)(setq THK 0.039370078))
        ((= "M" ITEM2) (setq IRD 0.5)(setq THK 1))
  ) ;_ end of cond
  (while (setq ORD (+ IRD THK))
  (command "_.fillet" "_r" IRD)
  (princ "\nSelect inside lines")
  (command "_.fillet" PAUSE PAUSE)
  (command "_.fillet" "_r" ORD)
  (princ "\nSelect outside lines")
  (command "_.fillet" PAUSE PAUSE)
)
  (princ)
) ;_ end of defun

(defun
     FLT15 (/ IRD THK ORD ITEM2)
  (setq ITEM2
         (strcase
           (getstring
             "\nType I or M to set appropriate units...   <I> for Imperial  or  <M> for Metric  "
           ) ;_ end of getstring
         ) ;_ end of strcase
  ) ;_ end of setq
  (cond ((= "I" ITEM2) (setq IRD 0.047244094)(setq THK 0.059055118))
        ((= "M" ITEM2) (setq IRD 1.2)(setq THK 1.5))
  ) ;_ end of cond
  (while (setq ORD (+ IRD THK))
  (command "_.fillet" "_r" IRD)
  (princ "\nSelect inside lines")
  (command "_.fillet" PAUSE PAUSE)
  (command "_.fillet" "_r" ORD)
  (princ "\nSelect outside lines")
  (command "_.fillet" PAUSE PAUSE)
)
  (princ)
) ;_ end of defun

 

 

If you set  CMDECHO to 1 , do it show the messages at the command line.

 

Or press F2 key to show TEXT SCREEN . 

 

As per my personal way , to set CMDECHO to 0 , it is like to walk in darkness. I ALWAYS set CMDECHO to 1 . 

If possible , upload the dwg here you need to apply such lisp 

 

 

 

Share this post


Link to post
Share on other sites
marko_ribar

I think that you actually don't need to use CMDECHO...

My suggestion is that you remove lines :

(command "_.fillet" "_r" IRD/ORD)

And replace them with :

(setvar 'filletrad IRD/ORD)

That mod. will remove unnecessary prompting of FILLET command and leave your prompting (princ "\nSelect inside/outside lines...") preferences over next invoking FILLET command with user random picks...

Personally I'd avoid using PAUSE syntax and instead literal "\\" - you may localize PAUSE intentionally and that would lead to error as this is protected syntax...

Next you may need error handling, but I don't really see it so important (you don't have anything to restore upon unexpected termination - ESC...)

And one more thing - try to avoid (getstring) that has single input - I'd rather use more appropriate (getkword) with adequate (initget 1 "Imperial Metric") call - 1 means that empty choice (ENTER) is not allowed in following (getkword) - look for examples with (getkword) - it should be something like "\n Type appropriate units [Imperial/Metric] : " - this thingy with [ ] brackets and capital letters and separator / allows user to make decision with either keyboard or mouse click - check it and you'll see what I mean...

As for CMDECHO, I don't like it's default value of 1, so I changed that in my acaddoc.lsp to 0, but then again it's good practice to save value to some var, then set it and at the end restore it - or alternatively use error handler for restoring its value - you will be sure it would reset correctly that way...

Share this post


Link to post
Share on other sites
Manila Wolf

Thank you for the interest devitg and marko.

 

It is 10-30pm here so no real time to digest your comments.

I have however prepared a drawing to help in the explanation.AMCF.dwg

 

I am indeed nervous about changing the CMDECHO values. It's easy for something to go wrong.

 

I will find time to evaluate your valued comments.

Thanks to both.

Share this post


Link to post
Share on other sites
BIGAL

Unless the cmdecho annoys you leave it on, the other time to turn off is when doing lots of commands and it would be nicer if not displayed. 

 

I would look at your fillet method if its 4 lines then I would use a ssget and fence option just drag a L over the lines and use the entities found. I have this will see if I can find its buried in a code. This method has been used on multiple fillets with a inside seed radius auto working out the width of each segment.

 

image.thumb.png.11bd0f823bb8b15ada682f6b100e3989.png

 

Found something but need to amend it. Seed radius is zero.

 

Edited by BIGAL

Share this post


Link to post
Share on other sites
Manila Wolf

Thanks for all replies.

 

As it stands, the lisp only shows the desired command prompts when CMDECHO is set to 0

Regarding CMDECHO, for myself I don't even need the command prompts because I know what the lisp does. The problem is when I pass the lisp on to the CAD operators in our office who most likely have never heard of CMDECHO.
I am trying to make it as foolproof as possible.

 

My thinking now is to maybe have a pop up message at the beginning of the routine giving a brief instruction of how to use.
That way, no need to interfere with the CMDECHO variable.

Something like this added at the beginning of the code: -

 

 (defun
     C:AMCF ()

              (alert "To fillet both the inside and outside bend radii based on sheet thickness: -
\nStep-1 ... For the first (or only bend) select the two INNER lines to create the INSIDE radius, then immediately after that select the two OUTER lines to create the OUTSIDE radius. > ENTER.
\nStep-2 ... If more than one bend repeat Step-1.
\nStep-3 ... Finally when all is done press ESC to finish."
              )

  (setq ITEM

 

Not my preferred scenario as I do like the way the lisp runs as if CMDECHO is set to 0.


Marko, now I will spend some time analysing your suggestions for improving way the the code is written.

 

Bigal,
your selection method looks like it has merit.
By the way, the code I have currently shown is for sheet thicknesses of 1mm and 1.5mm.
Once I am satisfied with the code I will be adding more thicknesses. (2mm, 2.5mm, 3mm, 4mm, 5mm and 6mm).
It is not always the case that the inside radius is the same value as the wall thickness.

 

Thanks again all.

Share this post


Link to post
Share on other sites
BIGAL

I tried to find this post a couple of days ago, the description was why I could not find, please try this. See image above for the 3 point pick. Auto works out second radius.

 

(defun c:RADx2 ()

  (setq pt1 (getpoint "Pick outside"))
  (setq pt2 (getpoint pt1 "Pick inside"))
  (setq pt3 (getpoint pt2 "Pick outside"))
  (setq rad (Getreal "enter Radius"))
  
  (setq lst (list pt1 pt2))
  (setq ss (ssget "F" lst (list (cons 0 "*line"))))
  
  (setq lst (list pt2 pt3))
  (setq ss2 (ssget "F" lst (list (cons 0 "*line"))))
  
  (setq obj (vlax-ename->vla-object (ssname ss 0)))
  (setq pt3 (vlax-curve-getclosestpointto obj pt2))
  (setq dist1 (distance pt2 pt3))
  
  (setq obj (vlax-ename->vla-object (ssname ss 1)))
  (setq pt4 (vlax-curve-getclosestpointto obj pt2))
  (setq dist2 (distance pt2 pt4))
  (setq distx (abs (- dist1 dist2)))
  
  (if (> dist1 dist2)
    (progn
      (setq temp pt3)
      (setq pt3 pt4)
      (setq pt4 temp)
    )
  )
  
  (setq obj (vlax-ename->vla-object (ssname ss2 0)))
  (setq pt5 (vlax-curve-getclosestpointto obj pt2))
  (setq dist1 (distance pt2 pt5))
  
  (setq obj (vlax-ename->vla-object (ssname ss2 1)))
  (setq pt6 (vlax-curve-getclosestpointto obj pt2))
  (setq dist2 (distance pt2 pt6))
  
  (if (> dist1 dist2)
    (progn
      (setq temp pt5)
      (setq pt5 pt6)
      (setq pt6 temp)
    )
  )
  (setvar 'filletrad rad)
  (command "fillet" pt3 pt5)
  (setq rad (+ rad distx))
  (setvar 'filletrad rad)
  (command "fillet" pt4 pt6)
)
(vl-load-com)
(c:test)

 

Edited by BIGAL

Share this post


Link to post
Share on other sites
Manila Wolf

Bigal,

Thanks for posting the code "RADx". I like the selection method. I hope to learn from it and if possible manipulate it, or follow some of it, to allow the user to key in wall thickness rather than inside radius. (This may take me some time 🙂).
The lisp I am trying to compile at the outset needs to accommodate the fact that the user does not know any radius values, only sheet thickness.


Looking at Marko's suggestions: -

 

Quote
On 1/11/2020 at 9:18 PM, marko_ribar said:

My suggestion is that you remove lines :

(command "_.fillet" "_r" IRD/ORD)

And replace them with :

(setvar 'filletrad IRD/ORD)

That mod. will remove unnecessary prompting of FILLET command and leave your prompting (princ "\nSelect inside/outside lines...") preferences over next invoking FILLET command with user random picks...

 

 

I understand the logic, but unfortunately I can not make this work. I still can't get the desired command line prompt. Maybe I am inserting lines of code incorrectly?

 

On 1/11/2020 at 9:18 PM, marko_ribar said:

Personally I'd avoid using PAUSE syntax and instead literal "\\" - you may localize PAUSE intentionally and that would lead to error as this is protected syntax...

 

Thank you. I understand this.

 

On 1/11/2020 at 9:18 PM, marko_ribar said:

And one more thing - try to avoid (getstring) that has single input - I'd rather use more appropriate (getkword) with adequate (initget 1 "Imperial Metric") call - 1 means that empty choice (ENTER) is not allowed in following (getkword) - look for examples with (getkword) - it should be something like "\n Type appropriate units [Imperial/Metric] : " - this thingy with [ ] brackets and capital letters and separator / allows user to make decision with either keyboard or mouse click - check it and you'll see what I mean...

 

I can see how much better this would be than the getstring approach. I tried to apply it but get this message: - "; error: bad argument type: numberp: nil" when I run the code.
This is how I am trying the "getkword" approach: -

 

(defun
     FLT1 (/ IRD THK ORD ITEM2)
(initget 1 "Imperial Metric")
(setq ITEM2 (cond (getkword "\nSelect appropriate units [Imperial/Metric] : ")))

  (cond ((= ITEM2 "Imperial") (setq IRD 0.019685039)(setq THK 0.039370078))
        ((= ITEM2 "Metric") (setq IRD 0.5)(setq THK 1))
(Princ)
  ) ;_ end of cond

  (while (setq ORD (+ IRD THK))
  (command "_.fillet" "_r" IRD)
  (princ "\nSelect inside lines")
  (command "_.fillet" "\\" "\\")
  (command "_.fillet" "_r" ORD)
  (princ "\nSelect outside lines")
  (command "_.fillet" "\\" "\\")
)
  (princ)
) ;_ end of defun

 

Obviously I have a lot to learn. 🙂

Share this post


Link to post
Share on other sites
Manila Wolf
3 hours ago, Manila Wolf said:

 

Quote
On 1/11/2020 at 9:18 PM, marko_ribar said:

My suggestion is that you remove lines :

(command "_.fillet" "_r" IRD/ORD)

And replace them with :

(setvar 'filletrad IRD/ORD)

That mod. will remove unnecessary prompting of FILLET command and leave your prompting (princ "\nSelect inside/outside lines...") preferences over next invoking FILLET command with user random picks...

 

 

I understand the logic, but unfortunately I can not make this work. I still can't get the desired command line prompt. Maybe I am inserting lines of code incorrectly?

 

 

I have played around a bit and come up with this: -

 

(defun
     FLT1 (/ IRD THK ORD ITEM2)
  (setq ITEM2
         (strcase
           (getstring
             "\nType I or M to set appropriate units...   <I> for Imperial  or  <M> for Metric  "
           ) ;_ end of getstring
         ) ;_ end of strcase
  ) ;_ end of setq
  (cond ((= "I" ITEM2) (setq IRD 0.019685039)(setq THK 0.039370078))
        ((= "M" ITEM2) (setq IRD 0.5)(setq THK 1))
  ) ;_ end of cond
  (setq ORD (+ IRD THK))
  (setvar 'filletrad IRD)
  (while (setq ln1 (entsel "\nSelect INNER line #1"))
  (if (setq ln2 (entsel"\nSelect INNER line #2"))
  (command ".fillet" ln1 ln2))
  (setvar 'filletrad ORD)
  (if (setq ln1 (entsel "\nSelect OUTER line #1"))
  (if (setq ln2 (entsel "\nSelect OUTER line #2"))
  (command ".fillet" ln1 ln2)))
  (setvar 'filletrad IRD)
  )
  (princ)
  ) ;_ end of defun

 

It works but if you use "entsel" it does not highlight the line during selection. If you miss the line you don't know it?

 

Share this post


Link to post
Share on other sites
BIGAL

The distx is the thickness of the material in my code so you could use a rule like 0.5 x distx is rad, so no need for user radius input that seems to match your 1mm THK

Share this post


Link to post
Share on other sites
Manila Wolf
2 hours ago, BIGAL said:

The distx is the thickness of the material in my code so you could use a rule like 0.5 x distx is rad, so no need for user radius input that seems to match your 1mm THK

 

Good day Bigal,

 

I wish it were as simple as that but it's not always the case that the inside radius = 0.5 x Wall Thickness.

Eventually, when I finish the code it will be based on the following fixed parameters: -

 

Wall 1mm    -  Inside Rad = 0.5mm  -  Outside Rad = 1.5mm
Wall 1.5mm  -  Inside Rad = 1.2mm  -  Outside Rad = 2.7mm
Wall 2mm    -  Inside Rad = 2mm    -  Outside Rad = 4mm
Wall 2.5mm  -  Inside Rad = 2mm    -  Outside Rad = 4.5mm
Wall 3mm    -  Inside Rad = 2mm    -  Outside Rad = 5mm
Wall 4mm    -  Inside Rad = 2.5mm  -  Outside Rad = 6.5mm
Wall 5mm    -  Inside Rad = 4mm    -  Outside Rad = 9mm
Wall 6mm    -  Inside Rad = 6mm    -  Outside Rad = 12mm

 

Outside radius is always inside radius + wall thickness.

 

When I initially uploaded the code I only show wall thicknesses as 1mm and 1.5mm.

Rather than uploading many lines of code I figured that if I can make the code work 1mm and 1.5mm then the addition of the other thicknesses would be a simple task.

 

 

 

Share this post


Link to post
Share on other sites
BIGAL

So are the lines representing a thickness they may be say 10mm apart hollow tube which is not what I based my answer on. Apart from asking for thickness the code could be changed pretty easy for radi, rado using a cond

 

(cond
((= Thick 1.0)(Setq radi 0.5 rado 1.5))
((= Thick 1.5)(setq Radi 1.2 rado 2.7))
..... 

)
(setvar 'filletrad radi)
  (command "fillet" pt3 pt5)
  
  (setvar 'filletrad rado)
  (command "fillet" pt4 pt6)

 

 

Share this post


Link to post
Share on other sites
Manila Wolf

Hi Bigal, thank you for your suggestions.

 

There are no hollows. Only sheets of various listed thicknesses.
currently showing sheet thicknesses of 1mm and 1.5mm.
Later I plan to add sheet thicknesses 2mm, 2.5mm, 3mm, 4mm, 5mm and 6mm.

I do see the logic of adding "radi, rado using a cond"
Another thought is whilst the fence "L" shape selection is very good it would need to be explained to every new user.


Unfortunately the whole lisp writing exercise is too complex for me so for that reason I have arrived at the following solution which works but could have been better if I could have been able to somehow apply the initget / getkword method and an error trap for the entsel.

 


;By MarkD a modified version of the following: - 
;an AutoLISP routine that changes the fillet radius to accomodate the inside and outside radii of formed sheet metal pieces.
;Cadalyst Tip1379.LSP:  FLT.LSP   Dual Fillets   (C)1997, Robert Dieckmann
;https://cadtips.cadalyst.com/2d-operations/dual-fillets

 (defun
     C:AMCF ()
  (setq ITEM
         (strcase
           (getstring
             "\nType one of the following relevant wall thicknesses...  <1>  <1.5>  "
           ) ;_ end of getstring
         ) ;_ end of strcase
  ) ;_ end of setq
  (cond ((= "1" ITEM) (FLT1))
        ((= "1.5" ITEM) (FLT15))
  ) ;_ end of cond
) ;_ end of defun

(defun
     FLT1 (/ IRD ORD ITEM2)
  (setq ITEM2
         (strcase
           (getstring
             "\nImperial or Metric?   Type  <I>  or  <M>  "
           ) ;_ end of getstring
         ) ;_ end of strcase
  ) ;_ end of setq
  (cond ((= "I" ITEM2) (setq IRD 0.019685039370079)(setq ORD 0.059055118110236));Set to 15 decimal places
        ((= "M" ITEM2) (setq IRD 0.5)(setq ORD 1.5))
  ) ;_ end of cond
  (setvar 'filletrad IRD)
  (while (setq ln1 (entsel "\nSelect INNER line #1"))
  (if (setq ln2 (entsel"\nSelect INNER line #2"))
  (command ".fillet" ln1 ln2))
  (setvar 'filletrad ORD)
  (if (setq ln1 (entsel "\nSelect OUTER line #1"))
  (if (setq ln2 (entsel "\nSelect OUTER line #2"))
  (command ".fillet" ln1 ln2)))
  (setvar 'filletrad IRD)
  )
  (princ)
  ) ;_ end of defun

(defun
     FLT15 (/ IRD ORD ITEM2)
  (setq ITEM2
         (strcase
           (getstring
             "\nImperial or Metric?   Type  <I>  or  <M>  "
           ) ;_ end of getstring
         ) ;_ end of strcase
  ) ;_ end of setq
  (cond ((= "I" ITEM2) (setq IRD 0.047244094488189)(setq ORD 0.106299212598425));Set to 15 decimal places
        ((= "M" ITEM2) (setq IRD 1.2)(setq ORD 2.7))
  ) ;_ end of cond
  (setvar 'filletrad IRD)
  (while (setq ln1 (entsel "\nSelect INNER line #1"))
  (if (setq ln2 (entsel"\nSelect INNER line #2"))
  (command ".fillet" ln1 ln2))
  (setvar 'filletrad ORD)
  (if (setq ln1 (entsel "\nSelect OUTER line #1"))
  (if (setq ln2 (entsel "\nSelect OUTER line #2"))
  (command ".fillet" ln1 ln2)))
  (setvar 'filletrad IRD)
  )
  (princ)
) ;_ end of defun

 

Share this post


Link to post
Share on other sites
BIGAL

You may need to make a "How to" Document for your lisps showing how lisps work the image took a couple of minutes to make just copy and paste to word etc images. We had one it had around 75 lisps in it. plus a stack of other how do I do that docs for when you forgot "how to do that".

 

The doc is a list of some of my stuff not the end user manual.

 

Lisp files march 2019-3.docx

Edited by BIGAL

Share this post


Link to post
Share on other sites
Manila Wolf

Hi Bigal,

 

Very impressive your ""How to" Document". I believe I can easily create something similar. Thank you for the inspiration.

So now I am going to try and implement your fence "L" shape selection in my code.

 

Here is my attempt. The problem I have is that I can't make it loop. By that I mean if there is more than one bend I would like to apply the lisp to one bend then move on to the next if there is one, the right click or enter to exit the lisp. I guess I have to place a "(while" in the code somewhere.

 

;By MarkD a modified version of the following: - 
;an AutoLISP routine that changes the fillet radius to accomodate the inside and outside radii of formed sheet metal pieces.
;Cadalyst Tip1379.LSP:  FLT.LSP   Dual Fillets   (C)1997, Robert Dieckmann
;https://cadtips.cadalyst.com/2d-operations/dual-fillets

 (defun C:AMCF ()
(vl-load-com)
  (setq ITEM
         (strcase
           (getstring
             "\nType one of the following relevant wall thicknesses...  <1>  <1.5>  "
           ) ;_ end of getstring
         ) ;_ end of strcase
  ) ;_ end of setq
  (cond ((= "1" ITEM) (FLT1))
        ((= "1.5" ITEM) (FLT15))
  ) ;_ end of cond
) ;_ end of defun

(defun
     FLT1 (/ IRD ORD ITEM2)

  (setq ITEM2
         (strcase
           (getstring
             "\nImperial or Metric?   Type  <I>  or  <M>  "
           ) ;_ end of getstring
         ) ;_ end of strcase
  ) ;_ end of setq
  (cond ((= "I" ITEM2) (setq IRD 0.019685039370079));Set to 15 decimal places
        ((= "M" ITEM2) (setq IRD 0.5))
  ) ;_ end of cond

(setq pt1 (getpoint " Pick outside, "))
  (setq pt2 (getpoint pt1 " Pick inside, "))
  (setq pt3 (getpoint pt2 " Pick outside, "))

  (setq lst (list pt1 pt2))
  (setq ss (ssget "F" lst (list (cons 0 "*line"))))
  
  (setq lst (list pt2 pt3))
  (setq ss2 (ssget "F" lst (list (cons 0 "*line"))))
  
  (setq obj (vlax-ename->vla-object (ssname ss 0)))
  (setq pt3 (vlax-curve-getclosestpointto obj pt2))
  (setq dist1 (distance pt2 pt3))
  
  (setq obj (vlax-ename->vla-object (ssname ss 1)))
  (setq pt4 (vlax-curve-getclosestpointto obj pt2))
  (setq dist2 (distance pt2 pt4))
  (setq distx (abs (- dist1 dist2)))
  
  (if (> dist1 dist2)
    (progn
      (setq temp pt3)
      (setq pt3 pt4)
      (setq pt4 temp)
    )
  )
  
  (setq obj (vlax-ename->vla-object (ssname ss2 0)))
  (setq pt5 (vlax-curve-getclosestpointto obj pt2))
  (setq dist1 (distance pt2 pt5))
  
  (setq obj (vlax-ename->vla-object (ssname ss2 1)))
  (setq pt6 (vlax-curve-getclosestpointto obj pt2))
  (setq dist2 (distance pt2 pt6))
  
  (if (> dist1 dist2)
    (progn
      (setq temp pt5)
      (setq pt5 pt6)
      (setq pt6 temp)
    )
  )
  (setvar 'filletrad IRD)
  (command "fillet" pt3 pt5)
  (setq IRD (+ IRD distx))
  (setvar 'filletrad IRD)
  (command "fillet" pt4 pt6)
  (princ)
  ) ;_ end of defun

(defun
     FLT15 (/ IRD ORD ITEM2)
  (setq ITEM2
         (strcase
           (getstring
             "\nImperial or Metric?   Type  <I>  or  <M>  "
           ) ;_ end of getstring
         ) ;_ end of strcase
  ) ;_ end of setq
  (cond ((= "I" ITEM2) (setq IRD 0.047244094488189)(setq ORD 0.106299212598425));Set to 15 decimal places
        ((= "M" ITEM2) (setq IRD 1.2)(setq ORD 2.7))
  ) ;_ end of cond

(setq pt1 (getpoint " Pick outside, "))
  (setq pt2 (getpoint pt1 " Pick inside, "))
  (setq pt3 (getpoint pt2 " Pick outside, "))

  (setq lst (list pt1 pt2))
  (setq ss (ssget "F" lst (list (cons 0 "*line"))))
  
  (setq lst (list pt2 pt3))
  (setq ss2 (ssget "F" lst (list (cons 0 "*line"))))
  
  (setq obj (vlax-ename->vla-object (ssname ss 0)))
  (setq pt3 (vlax-curve-getclosestpointto obj pt2))
  (setq dist1 (distance pt2 pt3))
  
  (setq obj (vlax-ename->vla-object (ssname ss 1)))
  (setq pt4 (vlax-curve-getclosestpointto obj pt2))
  (setq dist2 (distance pt2 pt4))
  (setq distx (abs (- dist1 dist2)))
  
  (if (> dist1 dist2)
    (progn
      (setq temp pt3)
      (setq pt3 pt4)
      (setq pt4 temp)
    )
  )
  
  (setq obj (vlax-ename->vla-object (ssname ss2 0)))
  (setq pt5 (vlax-curve-getclosestpointto obj pt2))
  (setq dist1 (distance pt2 pt5))
  
  (setq obj (vlax-ename->vla-object (ssname ss2 1)))
  (setq pt6 (vlax-curve-getclosestpointto obj pt2))
  (setq dist2 (distance pt2 pt6))
  
  (if (> dist1 dist2)
    (progn
      (setq temp pt5)
      (setq pt5 pt6)
      (setq pt6 temp)
    )
  )
  (setvar 'filletrad IRD)
  (command "fillet" pt3 pt5)
  (setq IRD (+ IRD distx))
  (setvar 'filletrad IRD)
  (command "fillet" pt4 pt6)
  (princ)
  ) ;_ end of defun

 

Share this post


Link to post
Share on other sites
BIGAL

Look at the while at enter thickness (setq ITEM Also if say all metric once chosen wrap it in a (if (not item2) so it skips asking again.

 

If you have known thickness say like 10 off them look at my Multi radio buttons.lsp this will let you use a dcl for size or use a library LISTBOX dcl there out there as well pick from a list.

 

(setq ans (atof  (ah:butts but "V"   '("Choose thickness " "  1" "  1.5" " 2" "  2.5" " 3" "  4" "  5" "  6" "  7"))))

image.png.e6dbed478d169048a3f985a634c9e575.png

Share this post


Link to post
Share on other sites
ronjonp

@BIGAL Have you ever thought of using popup_list over buttons? It uses a lot less real estate :)

 

Here's something I use to change a layer linetype:

image.png.0515b1bce015480dcb493d396697fe43.png

Share this post


Link to post
Share on other sites
BIGAL

ronjonp I did refer to using a listbox as it displays all options. The one I use was thanks to Alanjt. There are many ways to choose as you suggest.

 

(setq lst (list "1.0" "1.5" "2.0" "2.5" "3.0" "4.0" "5.0"))
(if (not AT:ListSelect)(Load "listselect"))
(setq thick (atof (nth 0 (AT:ListSelect "Please choose " "Thickness"   10 10   "false" lst ))))

 

image.png.30a42ea39f26fc672f35699a691d9be3.png

 

The multi radio buton saves 1 mouse click as when you pick a button the dcl closes it also saves the last answer as the default button for next use so can just pick OK.

The Multi radio buttons has a spacer in it to actually make the dcl longer it has a setting of <12 you could remove the (if  or add a lower number. Images from Briscad slightly different in Autocad a bit larger.

 

image.png.801041361398e0b18e40c2c622f5d529.png

listselect.lsp

Edited by BIGAL

Share this post


Link to post
Share on other sites
Manila Wolf

Hi Bigal,

 

16 hours ago, BIGAL said:

Look at the while at enter thickness (setq ITEM

 

I tried this and it seems it returns me to the start of the lisp where it asks "Imperial or Metric". 

Sorry if my previous explanation was not so clear. What I am trying to achieve is a repeat of this part of the code to perform more Fence "L" selections before right clicking to exit: -

 

  (setvar 'filletrad IRD)
  (command "fillet" pt3 pt5)
  (setq IRD (+ IRD distx))
  (setvar 'filletrad IRD)
  (command "fillet" pt4 pt6)

 

16 hours ago, BIGAL said:

Also if say all metric once chosen wrap it in a (if (not item2) so it skips asking again.

 

This looks like it may be very useful.  I will try and understand that later.

 

Also the radio buttons look very good. Again I will look later and try to implement.

 

Thanks for your help and suggestions.

Edited by Manila Wolf
Improved description

Share this post


Link to post
Share on other sites
BIGAL

This allows for metric and inch hopefully got numbers correct. It works with lines only I will fix up for plines shortly.

 

;By Alan H Jan 2020 info@alanh.com.au
;an AutoLISP routine that changes the fillet radius to accomodate the inside and outside radii of formed sheet metal pieces.


(defun C:AMCF ( /   BUT DIST1 DIST2 DISTX IRD IRO ITEM ITEM2 LST OBJ PT1 PT2 PT3 PT4 PT5 PT6 SS SS2 TEMP)

(vl-load-com)
  ;(setq ITEM
   ;      (strcase
    ;       (getstring
     ;        "\nType one of the following relevant wall thicknesses...  <1>  <1.5>  "
      ;     ) ;_ end of getstring
       ;  ) ;_ end of strcase
;  ) ;_ end of setq


(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (not but)(setq but 1))

(while  (setq pt1 (getpoint " Pick outside, Enter to exit "))
  (setq pt2 (getpoint pt1 " Pick inside, "))
  (setq pt3 (getpoint pt2 " Pick outside, "))

(setq item (atof (ah:butts but "V"   '("Choose thickness " "  1" "  1.5" " 2" "  2.5" " 3" "  4" "  5" "  6" ))))

(if (not item2)
(setq item2 (ah:butts 1 "V"   '("Choose Inch mm " "INCH" "MM" )))
)

  (cond 
  ((and (= 1 ITEM)(= item2 "MM"))(setq IRD 0.5 IRO 1.5))
  ((and (= 1.5 ITEM)(= item2 "MM"))(setq IRD 1.2 IRO 2.7))
  ((and (= 2 ITEM)(= item2 "MM"))(setq IRD 2.0 IRO 4.0))
  ((and (= 2.5 ITEM)(= item2 "MM"))(setq IRD 2.0 IRO 4.5))
  ((and (= 3 ITEM)(= item2 "MM"))(setq IRD 2.0 IRO 5.0))
  ((and (= 4 ITEM)(= item2 "MM"))(setq IRD 2.5 IRO 6.5))
  ((and (= 5 ITEM)(= item2 "MM"))(setq IRD 4.0 IRO 9.0))
  ((and (= 6 ITEM)(= item2 "MM"))(setq IRD 6.0 IRO 12.0))
  ((and (= 1 ITEM)(= item2 "INCH"))(setq IRD 0.019685039 IRO 0.0590551))
  ((and (= 1.5 ITEM)(= item2 "INCH"))(setq IRD 0.04724409 IRO 0.106299212598))
  ((and (= 2 ITEM)(= item2 "INCH"))(setq IRD 0.07874 IRO 0.15748031496))
  ((and (= 2.5 ITEM)(= item2 "INCH"))(setq IRD 0.07874 IRO 0.17716535433))
  ((and (= 3 ITEM)(= item2 "INCH"))(setq IRD 0.07874 IRO 0.1968503937))
  ((and (= 4 ITEM)(= item2 "INCH"))(setq IRD 0.09842519685 IRO 0.25590551181))
  ((and (= 5 ITEM)(= item2 "INCH"))(setq IRD 0.15748031496 IRO 0.35433070866))
  ((and (= 6 ITEM)(= item2 "INCH"))(setq IRD 0.23622047244 IRO 0.47244094))
  ) ;_ end of cond
  
;  (setq ITEM2
   ;      (strcase
    ;       (getstring
     ;        "\nImperial or Metric?   Type  <I>  or  <M>  "
      ;     ) ;_ end of getstring
       ;  ) ;_ end of strcase
;  ) ;_ end of setq
 ; (cond ((= "I" ITEM2) (setq IRD 0.019685039370079));Set to 15 decimal places
  ;      ((= "M" ITEM2) (setq IRD 0.5))
 ; ) ;_ end of cond



  (setq lst (list pt1 pt2))
  (setq ss (ssget "F" lst (list (cons 0 "*line"))))
  
  (setq lst (list pt2 pt3))
  (setq ss2 (ssget "F" lst (list (cons 0 "*line"))))
  
  (setq obj (vlax-ename->vla-object (ssname ss 0)))
  (setq pt3 (vlax-curve-getclosestpointto obj pt2))
  (setq dist1 (distance pt2 pt3))
  
  (setq obj (vlax-ename->vla-object (ssname ss 1)))
  (setq pt4 (vlax-curve-getclosestpointto obj pt2))
  (setq dist2 (distance pt2 pt4))
  (setq distx (abs (- dist1 dist2)))
  
  (if (> dist1 dist2)
    (progn
      (setq temp pt3)
      (setq pt3 pt4)
      (setq pt4 temp)
    )
  )
  
  (setq obj (vlax-ename->vla-object (ssname ss2 0)))
  (setq pt5 (vlax-curve-getclosestpointto obj pt2))
  (setq dist1 (distance pt2 pt5))
  
  (setq obj (vlax-ename->vla-object (ssname ss2 1)))
  (setq pt6 (vlax-curve-getclosestpointto obj pt2))
  (setq dist2 (distance pt2 pt6))
  
  (if (> dist1 dist2)
    (progn
      (setq temp pt5)
      (setq pt5 pt6)
      (setq pt6 temp)
    )
  )
  (setvar 'filletrad IRD)
  (command "fillet" pt3 pt5)

  (setvar 'filletrad IRO)
  (command "fillet" pt4 pt6)
  
  ) ; while
  
  (princ)


) ;_ end of defun

 

Edited by BIGAL

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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