Drawing Lines

Drawing Lines

nathanwheeler27
Advocate Advocate
962 Views
7 Replies
Message 1 of 8

Drawing Lines

nathanwheeler27
Advocate
Advocate

HI,

 

I have a function that draws a bunch of lines and hatch based on what the user inputs. I am having issues with the points for the lines being inaccurate kinda randomly. It seems like the points will occasionally attach to other points or something and arithmetic functions don't always work.

 

For example, I have lines drawn using "pt5" and "pt8", which work correctly. But when it gets down to the while statement, "(car pt5)" & "(car pt8)" return the correct x-value, yet the y-values are all wrong. The y-values end up matching the y-value from other points not shown.

 

 

(setq pt5 (list (- (car pt3) FtgHeel) (cadr pt3)) ; left side of heel
      pt8 (list (car pt7) (cadr pt4))) ; top right of toe

(command "line" pt5 pt8 ""); Works correctly

(setq cnt 1
      maxcnt (fix (/ (+ StemHeight CurbHeight) 8)))

(while (<= cnt maxcnt)
      (command "line" (list (car pt5) (+ (cadr pt5) (* 8 cnt)))
                  (list (car pt8) (+ (cadr pt8) (* 8 cnt))) "")
      (setq cnt (1+ cnt))
) ; while

 

 

 

The above while statement draws the red lines below which should be 8" apart. For some reason it skips over the green lines (I added manually), one of the red lines isn't even an 8" increment, and it is drawing multiple red lines over top of each other.

 

nathanwheeler27_0-1600057117730.png

 

If I switch pt5 and pt8, which should be the same line, just drawn backwards, it draws the lines even crazier.

 

(command "line" (list (car pt8) (+ (cadr pt8) (* 8 cnt)))
            (list (car pt5) (+ (cadr pt5) (* 8 cnt))) "")

 

nathanwheeler27_0-1600057741722.png

 

 

I can provide the whole thing, but I am hoping its just an issue with how I am setting the pt variables?

I have been dealing with this over and over again as I go through this script. Its like there is some crazy order of operations I am just not getting.

 

Thank you

 

0 Likes
Accepted solutions (2)
963 Views
7 Replies
Replies (7)
Message 2 of 8

hak_vz
Advisor
Advisor
Accepted solution

Try this:

 

(setq pt5 (list (- (car pt3) FtgHeel) (cadr pt3)) ; left side of heel
      pt8 (list (car pt7) (cadr pt4))) ; top right of toe

(command "line" "none" pt5 "none" pt8 ""); Works correctly

(setq cnt 1
      maxcnt (fix (/ (+ StemHeight CurbHeight) 8.0)))

(while (<= cnt maxcnt)
      (command "line" "none" (list (car pt5) (+ (cadr pt5) (* 8 cnt))) "none" (list (car pt8) (+ (cadr pt8) (* 8 cnt))) "")
      (setq cnt (1+ cnt))
) ; while

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 3 of 8

nathanwheeler27
Advocate
Advocate

Amazing, I love a solution that takes no effort and works right away 😄 Thanks.

It appears to be working. As I continue to add to the script, hopefully this permanently fixes the random bugs. 

0 Likes
Message 4 of 8

ВeekeeCZ
Consultant
Consultant
Accepted solution

Those "random bugs" were caused by running OSNAPs during the lisp. Anywhere you need to define a point within a command (command "line" pnt1 pnt2), you need to make sure that OSNAPs are off.

 

so you can add "_non" temp-override prior to each point - as @hak_vz did

you can set osmode to 0 or turn it off.

you can change OSNAPCOORD

 

HTH

Message 5 of 8

nathanwheeler27
Advocate
Advocate

Thank you, that explanation is helpful.

Message 6 of 8

Sea-Haven
Mentor
Mentor

Look into osnap set say 1 snap then do osmode this gives you the correct osnap value as you may want the users to pick a certain point like an end.

 

(setq oldsnap (getvar 'osmode))
do your thing
(setvar 'osmode 1)
do your thing
(setvar 'osmode 0)
draw stuff

(setvar 'osmode oldsnap) ; do at end to set back to normal snaps or set to a value eg 47
Message 7 of 8

nathanwheeler27
Advocate
Advocate

I've recently seen several examples of this, and until now, I glanced over them thinking it didn't apply to me... oops.

0 Likes
Message 8 of 8

Sea-Haven
Mentor
Mentor

Any problems can often be tracked to osnap if in doubt osmode 0.

0 Likes