Issue while generating line segments with a lisp code

Issue while generating line segments with a lisp code

Anonymous
Not applicable
1,573 Views
10 Replies
Message 1 of 11

Issue while generating line segments with a lisp code

Anonymous
Not applicable

Hello Everyone,

I am using the following AutoLISP code to generate line segments (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)
                    (rtos (distance p q) 2)
                    (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)
        )
    )
)

and the sample input for which the above code works fine is the following 

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

But I am not sure why the diagram is not created for an input where more data points are present.

Could someone kindly look at the input available here? I am not sure why the drawing isn't created for this data.

0 Likes
1,574 Views
10 Replies
Replies (10)
Message 2 of 11

pbejse
Mentor
Mentor

A graph was created. although it doesnt look anything that make sense

 

chaos.png

 

Looks like somebodys john hancock or a super drunk guy handwriting

Text removed for clarity

 

0 Likes
Message 3 of 11

hak_vz
Advisor
Advisor

Everything is OK.

In provided data set you have a bunch of 3d points, and as a result you receive 3d graph. Use free orbit and look at the graph from different viewpoint.

 

 

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.
0 Likes
Message 4 of 11

Anonymous
Not applicable

 

That's the expected output! Thanks for posting

Could you please check for the second input updated in the same file here?

 

I think there is a problem when the coordinates are negative. The drawing isn't created.

 

 

 

0 Likes
Message 5 of 11

Anonymous
Not applicable

Could you please check if it works fine with the second set of points updated here ( test2)

0 Likes
Message 6 of 11

pbejse
Mentor
Mentor

@Anonymous wrote:

 

That's the expected output! Thanks for posting

Could you please check for the second input updated in the same file here?


Here you go

 

Graph1 and graph2 as dwg.

 

BTW: its on 3D view now when you open the file.

 

 

0 Likes
Message 7 of 11

hak_vz
Advisor
Advisor

I have tested it on that data set too. It is a 3d graph.

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.
0 Likes
Message 8 of 11

Anonymous
Not applicable

@hak_vz  @pbejse 

I've been trying to run this code from python for generating these diagrams and the output dxf files

aren't generated for the inputs posted above (test1 and 2). The output dxf file is created successfully for the sample 2D input posted in the original post. Could you please suggest if there is anything that has to be modified in the code for the 3D data points?

 

Please note: The function in lisp file is shared in the original post.

0 Likes
Message 9 of 11

hak_vz
Advisor
Advisor

Lisp code seems written ok, and there shouldn't be problem with 2s or 3d point, with positive or negative coordinate value.

 

When you run python code does it finish with "Process Finished"      

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.
0 Likes
Message 10 of 11

Anonymous
Not applicable

This is what I find

 

deepam3HBK2_0-1602609501783.png

 

while running for test2. Unfortunately, I find only quit status and not `process completed`

 

test0 with 2D points runs fine without any issue from python.

 

 

 

0 Likes
Message 11 of 11

hak_vz
Advisor
Advisor

try to replace

 

 

'(setvar "SECURELOAD" *LOAD_SECURITY_STATE*)\n'

 

 

with

 

 

"(setvar 'SECURELOAD *LOAD_SECURITY_STATE*)\n"

 

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