Jump to content

coordinate in list not found


MJLM

Recommended Posts

I have a a couple of connected lines in Autocad representing a pipe network. I have a simple lisp routine that parses through all lines and writes in a list all intersections like that

 

(defun nodes (/ s ent i p a b w k)    ;  creates text labeling on each intersection

 (setq s (ssget "X" '((0 . "LINE"))))
  
 (setq pl nil)
 (repeat (setq i (sslength s))
(setq ent (entget (ssname s (setq i (1- i)))))
       (setq p (cdr (assoc 10 ent)))
(if (not (member p pl))
	(progn
		(setq k 0)
		(foreach w pl
			(if (not (equal w p 0.001))
				(setq k (1+ k))
			)
		)
		(if (= k (length pl))
			(setq pl (append pl (list p)))
		)
	)
)
				
       (setq p (cdr (assoc 11 ent)))
(if (not (member p pl))
	(progn
		(setq k 0)
		(foreach w pl
			(if (not (equal w p 0.001))
				(setq k (1+ k))
			)
		)
		(if (= k (length pl))
			(setq pl (append pl (list p)))
		)
	)
)   
 )

  (princ)
)

 

Using this list I want to number these nodes for the lines connected like that

 

So parsing through each line I have:

(setq pt10 (assoc 10 lineprop))
(setq pt11 (assoc 11 lineprop))

(setq node1 (itoa (1+ (vl-position (cdr pt10) pl))))
(setq node2 (itoa (1+ (vl-position (cdr pt11) pl))))

 

Here comes my problem. For some reason a point (coordinate) in the pl list is not recognized and gives error that it can not find the (cdr ptxx) in the pl list although apparently it is the same.

I tried to type manually also

!pl

returns: ((0.0 0.0 0.09) (5.0 0.0 0.0) ... (3.0 4.0 5.0) ... (7.0 6.0 6.0) (10.0 6.0 6.0))

 

(member '(3.0 4.0 5.0) pl)

returns: nil

 

I understand that the (3.0 4.0 5.0) is not 100% identical with the point in the list. But how can I correct this problem?

 

Any help would be appreciated.

Link to comment
Share on other sites

You need to check with every list of coordinates of the list with a fuzz factor .

 

eg.

(setq o    (car (entsel "\n Select line :"))
     pt10 (assoc 11 (entget o))
     )

(setq i 0)

(vl-position
 nil
 (mapcar '(lambda (q)
            (if (not (equal (cdr pt10) q 1e-)
              (setq i (1+ i))))
         pl)
 )

Where the variable " i " represents the location of that list of coordinate in the list pl since you are looking for that ,otherwise remove it if you don't want it .

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