Problem with number of decimal places in list function(?).

Problem with number of decimal places in list function(?).

Piotr.M.
Explorer Explorer
1,863 Views
15 Replies
Message 1 of 16

Problem with number of decimal places in list function(?).

Piotr.M.
Explorer
Explorer

Hi!

I have a problem probably with number of decimal places in list function.

Basically it's a program that draw a polygons with specified offset between them. I showed how it works in attached .dwg file. It works only when that I'm using are integers (without decimal points). When points have real numebers in coordinates everything goes totally casual(at least for me). The difference between two groups of the rectangles at the right of instruction rectangle in .dwg file is that the coordinates in te far right have numbers after decimal in coordinates.

 

Thanks in advance!

 

0 Likes
1,864 Views
15 Replies
Replies (15)
Message 2 of 16

ВeekeeCZ
Consultant
Consultant

Did you try turning off OSNAPs?

0 Likes
Message 3 of 16

Piotr.M.
Explorer
Explorer

snapping isn't the problem, and the clue of this program is that the point's should be defined by snapping to corners of rectangles

0 Likes
Message 4 of 16

Piotr.M.
Explorer
Explorer

Basically this program should work for every coordinates include real numbers.

0 Likes
Message 5 of 16

ВeekeeCZ
Consultant
Consultant

@Piotr.M. wrote:

Basically this program should work for every coordinates include real numbers.


 

Sure. That's all I can say unless you post the code.

0 Likes
Message 6 of 16

Piotr.M.
Explorer
Explorer

oh sorry I forgot about that. I wrote that code in one day after one day of learning, so the code can be quite "rough". Sorry about that.

0 Likes
Message 7 of 16

ВeekeeCZ
Consultant
Consultant

First of all, you are missing about 4 right parenthesis!! Debug your code yourself.

 

Then, I'm pretty sure that I was right about the OSNAPs. 

When you're setting some points within the command function (like your (command "pline"...)) you have to turn the osnaps off. If they are active during that function, you'll get quite an unpredictable result..., basically the same as your current issue.

 

About integers vs. real. I can see that you're using the (getreal) function for the OF variable. That's good, the OF would be always real even if you type "an integer". Basically, all values of your variables are always reals. That would not be a cause of your issues. 

 

(defun c:XZET (/ *error* osm ip1 ip2 ip3 ip4 op1 op2 op3 op4 2xOF
	       OF topwidth hftopwidth leftwidth hfleftwidth rightwidth hfrightwidth bottomwidth hfbottomwidth
	       cp11 p11 ycp12 cp12 xcp13 cp13 cp14 cp31 p31 ycp32 cp32 xcp33 cp33 cp34 p33 p36 p32 p34 p35 p37 p13 p16 p12 p14 p15 p17)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg))
      ); if
    (if osm (setvar 'OSMODE osm))
    (princ)
    ); defun -- *error*
  
  (setq ip1 (getpoint "\nset corner points of INTERNAL rectangle start from left upper corner and go clockwise: "))
  ...
  (setq p17 (list (car op1)(cadr p16)))
  (setq osm (getvar 'OSMODE))
  (setvar 'OSMODE 0)
  (command "pline" op1 op2 p34 p33 p32 p31 ip2 p15 p16 p17 "c")
  (command "pline" p14 p13 p12 p11 ip4 p35 p36 p37 op3 op4 "c")
  ;(command "pline" p14 p13 p12 p11 ip4 p35 p36 p37 op3 op4 )
  ;(command "line" cp13 cp33)
  ;(setq horwidth (distance p2 p3))
  ;(setq verwidth (distance p1 p3))
  ;(command "line" p1 p4 "c")
(setvar 'OSMODE osm) (prin1 cp33) )

 

0 Likes
Message 8 of 16

Piotr.M.
Explorer
Explorer

Code that you are added. What does it doing? 

About os snapping. I can't get it. I need object snapping to do that program. If I will change pline to line, does it will change anything?

0 Likes
Message 9 of 16

Piotr.M.
Explorer
Explorer

Btw I didn't get to debugging yet 🙂 

0 Likes
Message 10 of 16

Piotr.M.
Explorer
Explorer

I'm quite sure that the problem are real numbers. Because even if I making the polygons by os snapping everything is fine. 

0 Likes
Message 11 of 16

ВeekeeCZ
Consultant
Consultant

@Piotr.M. wrote:

I'm quite sure that the problem are real numbers. Because even if I making the polygons by os snapping everything is fine. 


 

Ok, let's give it a try.

Give me something that I can follow - code that works, steps you do, list of values you set which works and which don't.

A video would be best...

0 Likes
Message 12 of 16

Piotr.M.
Explorer
Explorer

Till now... It seems that you had right. For os snapping it doesn't work every time. I will record a video

 

0 Likes
Message 13 of 16

ВeekeeCZ
Consultant
Consultant

I'll give you an explanation later. If anyone doesn't. But do a search yourself. That is like the most popular issue of LISP coding.

 

Until that, go to Options/User Preferences/Priority for Coord Data Entry and tick the second option - Keyboard entry.

0 Likes
Message 14 of 16

Piotr.M.
Explorer
Explorer

On this windows built-in video recorder not everything is visible, but first of all I'm loading the attached program. Then I'm entering 8 points and define 2xOF variable as 10. Everything else as showed.

0 Likes
Message 15 of 16

Kent1Cooper
Consultant
Consultant

The difference is not that the left-side points are whole-number coordinates and the right-side ones are not, but because you did the left one with running Object Snap turned off, and right right one with it turned on.  Try doing the right one with Osnap on only until after you've picked 7 points, then turn it off [you can hit F3, rather than pick on the icon in the status bar], then type in  [or Ctrl+right-click and pick from the list] END or INT to snap to the corner for the 8th point, so that when it gets to drawing things, Osnap is off.  That's what @ВeekeeCZ's suggestion in Message 7 does, though it leaves Osnap on while you pick all  the points [assuming it's already on when you start], and turns it off before drawing things.  You would need to incorporate that into your [corrected] code, and could also incorporate turning Osnap on, in case it might not be on already when you call up the command.

Kent Cooper, AIA
0 Likes
Message 16 of 16

Piotr.M.
Explorer
Explorer

You had right!!! 😄 when I'm performs all the instruction that you gave me, everything works just fine! Now I need to implement turning of and on os snapping in right moment and hope that everything will be fine. 

 

Thank you master!

0 Likes