Jump to content

Variables keep staying the same...


Lee Mac

Recommended Posts

I am writing a program that will draw a pipe or flange (plan or elevation) and am using "IF" script to set my variables:

 

i.e.

   (if
           (= pipesize 100)
               (progn
                   (setq
                         pipeod   114.3
                         pipeid    102.3
                   ) ; end setq
               ) ; end progn
        ) ; end if

 

A program will then draw the pipe (plan or elevation) using these values.

 

However, sometimes when I choose a different pipe size, the variables stay the same as they were when the previous pipe size was selected, (even though the program tells them to be set differently).

 

(Hope all that made sense! :P)

 

Any Ideas?

Link to comment
Share on other sites

Not sure what you are doing because there is not enough information for me.

BUT guessing you are going to be setting up a group of pipe sizes, I would do

something like this:

 

;;  var pipes = the pipe Size
;;                      [size OD ID]
(setq PipeSizes '((100 114.3 102.3)
                 (200 214.3 202.3)
                 (300 314.3 302.3)
                 ))
(if (setq data (assoc pipes PipeSizes))
  (setq pipeod  (cadr data)
        pipeid  (caddr data))
  (alert "Error - No pipe size in list")
 )

Link to comment
Share on other sites

After all that, I have figured out that the reson that my variables were staying the same was that I had repeated a variable name. Problem Solved!

 

However, I now have another problem.... (I hear you groan...)

 

I have tried to attach the LISP, but the filesize is 23.4KB so I'll try to explain my problem as best I can. The problem is in the 'fillet' section. I cannot get the program to fillet selected lines, I just get an entity name as a result.

 

I have drawn an elevation of a flange, and, after every line is created, I have assigned a variable to that entity using the entlast command.

 

I have then attempted to fillet pairs of lines using a radius of 2. However when I try to fillet, an entity name is returned and the lines are not filleted.

 

Any help would be much appreciated.

Link to comment
Share on other sites

This allows for multi line filleting it uses 3 picks to work out the direction of fillet usefull where dual lines cross you have 4 fillet options

(setq ncr (getpoint "\npick point on inside near corner: "))
(command "zoom" "c" ncr zsc)
;perrp is 128
(setq old_mode (getvar "osmode")) 
(setvar "osmode" 512)
;(command "osnap" "near")
(princ "\nPick 1st inner wall: ")
(COMMAND "_.LINE" ncr "_perp" pause "")
(setq tp1 (getvar "lastpoint"))
(setq tpp1 (entget (entlast)))
(setq pt1 (cdr (assoc 10 tpp1))) 
(setq pt2 (cdr (assoc 11 tpp1))) 
; check that angle is 90 in correct direction
(SETQ ANG1 (ANGLE pt1 pt2))
(COMMAND "ERASE" "L" "")
(princ "\nPick  2nd inner wall: ")
(COMMAND "_.LINE" ncr "_perp" pause "")
(setq tp2 (getvar "lastpoint"))
(setq tpp2 (entget (entlast)))
(setq pt3 (cdr (assoc 10 tpp2))) 
(setq pt4 (cdr (assoc 11 tpp2))) 
; check that angle is 90 in correct direction
(SETQ ANG2 (ANGLE pt3 pt4))
(COMMAND "ERASE" "L" "")
(setvar "osmode" 0)
(command "fillet" tp1 tp2)
(setq tp3 (polar tp1 ang1 w4)) 
(setq tp4 (polar tp2 ang2 w4))
(command "fillet" tp3 tp4)  

 

just replace w4 with your width

 

I had another lisp trying to find it, would any number of fillets multiple lines and dont need to know the width of parrallel lines it uses a start point you then drag a line over the first group then the second group hey presto all filleted. If thats usefull I can tell you that it uses the intersection point of a new line with the old lines its very fast to use.

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