1

This is a followup to my previous post here

I've a 2D geometry created using the following code, ref.

(defun graph ( pts sls tls )

    (   (lambda ( l )
            (foreach x l (text (cdr x) (itoa (car x)) 0.0 1))
            (mapcar
               '(lambda ( a b / p q r )
                    (setq p (cdr (assoc a l))
                          q (cdr (assoc b l))
                          r (angle p q)
                    )
                    (entmake (list '(0 . "LINE") (cons 10 p) (cons 11 q) '(62 . 8)))
                    (text
                        (mapcar '(lambda ( x y ) (/ (+ x y) 2.0)) p q)
                        (roundupto (distance p q) 12.4)
                        (if (and (< (* pi 0.5) r) (<= r (* pi 1.5))) (+ r pi) r)
                        2
                    )
                )
                sls tls
            )
        )
        (mapcar 'cons (vl-sort (append sls tls) '<) pts)
    )
)
(defun text ( p s a c )
    (entmake
        (list
           '(0 . "TEXT")
            (cons 10 p)
            (cons 11 p)
            (cons 50 a)
            (cons 01 s)
            (cons 62 c)
           '(40 . 2)
           '(72 . 1)
           '(73 . 2)
        )
    )
)

(defun roundupto ( x m / d r )
    (setq d (getvar 'dimzin))
    (setvar 'dimzin 8)
    (setq r (rtos (* m (fix (+ 1 -1e-8 (/ x (float m))))) 2 8))
    (setvar 'dimzin d)
    r
)

Input:

(graph
   '((75 25) (115 45) (90 60) (10 5) (45 0) (45 55) (0 25) (10 50) (115 25))
   '(1 1 1 2 2 3 4 4 6 7 2)
   '(2 4 5 3 6 6 5 7 7 8 9)
)

Output:

enter image description here

The actual dimensions don't match the value displayed in the text (in yellow) over the lines. For instance, 62 is the value displayed and 54.0833 is the actual dimension. And I want to rescale the actual lengths to the values displayed, in yellow, over the lines. I understand the coordinates displayed in the input provided above have to be varied. Probably, the first coordinate can be fixed and the subsequent coordinates can be shifted.

Any suggestions on how to do this will be really helpful.

EDIT: The solution provided here in an answer to my previous post Scaling lengths in an AutoCAD diagram scales only the dimension displayed in yellow using the output obtained from roundupto function. The purpose behind posting this question is to ask for suggestions for scaling the actual lengths and not just the dimensions displayed in yellow.

EDIT2: Adding additional details

If one directly loads the input file in AutoCAD, the yellow text displayed in the following image is the actual dimensions enter image description here

And I want to convert the dimensions to the corresponding yellow labels displayed in the following image: enter image description here

Note: The labels displayed in the second image in EDIT2 were altered externally using an AutoLISP code to merely show how the actual lengths of the corresponding lines have to be scaled. In the first image displayed in EDIT2, the edge labels exactly match the lengths of the corresponding lines.

Natasha
  • 1,111
  • 5
  • 28
  • 66
  • Does this answer your question? [Scaling lengths in an AutoCAD diagram](https://stackoverflow.com/questions/60135396/scaling-lengths-in-an-autocad-diagram) – Lee Mac Apr 17 '20 at 16:55
  • 2
    Please note that the comment *"Does this answer your question?"* is automatically generated when you mark a question as a duplicate, which I feel that this is - I would not phrase the comment in such a manner. – Lee Mac Apr 17 '20 at 18:43
  • 1
    @LeeMac yep they changed the close voting quite a bit to be more "friendly" but most of them makes no sense anymore and just confuses... voting more or less only from memory (what the real cause was) – Spektre Apr 19 '20 at 08:53
  • Thanks for the clarification about the comment. I look forward to receiving suggestions on how to proceed with the question posted. Many thanks! – Natasha Apr 23 '20 at 06:26

1 Answers1

0

Is there a constant error factor on all values or does it differ on each one? I mean if you calculate 60/54.0833 you get roughly 1.13. If you do this on the other lengths you get what?
If there is a constant "zoom factor" you could multiply your vertices with that and afterwards change the labeling (the yellow numbers).

I admit, I do not know AutoCAD especially well, so I just can give hints, no solutions in code unless you would talk me through your code syntax.

I would suspect some rounding or division errors to be the reason for the value discrepancies. Can you check on that? For example is a b / p q r an integer or a float result? How does roundupto work? which precision has pi? Can you truncate or normalize your values to all be the same precision (like "to three digits behind the comma", for example)?
What are the meanings of the parameters slsand tls? pts I could identify as "list of points" from the input you posted.

Antares
  • 605
  • 3
  • 14