Jump to content

Recommended Posts

Posted

From a SSGET at a

 

(setq ins-pt '(785765.0 9.28376e+006 0.0) )

 

 

(setq ent-ss (ssget "_c" ins-pt ins-pt '((0 . "LINE") )))

 

I got all its 10 and 11 code , as I do not know wich one are on the INS-PT.

 

I sort it to Z value and got it ,

 

(setq pt-list (list '(785766.0 9.28375e+006 2418.41)
'(785768.0 9.28375e+006 2420.24)
'(785760.0 9.28377e+006 2421.07)
'(785769.0 9.28375e+006 2421.72)
'(785770.0 9.28376e+006 2422.19)
'(785770.0 9.28376e+006 2422.24)
'(785765.0 9.28376e+006 2422.47)
'(785765.0 9.28376e+006 2422.47)
'(785765.0 9.28376e+006 2422.47)
'(785765.0 9.28376e+006 2422.47)
'(785765.0 9.28376e+006 2422.47)
'(785765.0 9.28376e+006 2422.47)
'(785765.0 9.28376e+006 2422.47)
'(785765.0 9.28376e+006 2422.47)
'(785762.0 9.28377e+006 2422.77)
'(785763.0 9.28377e+006 2422.91)
))

 

It is clear that my common point is

 

(785765.0 9.28376e+006 2422.47)

 

How can I get it from the LIST.?

Posted
From a SSGET at a

 

(setq ins-pt '(785765.0 9.28376e+006 0.0) )

 

 

(setq ent-ss (ssget "_c" ins-pt ins-pt '((0 . "LINE") )))

I got all its 10 and 11 code , as I do not know wich one are on the INS-PT.

 

I sort it to Z value and got it ,

 

(setq pt-list (list '(785766.0 9.28375e+006 2418.41)
'(785768.0 9.28375e+006 2420.24)
'(785760.0 9.28377e+006 2421.07)
'(785769.0 9.28375e+006 2421.72)
'(785770.0 9.28376e+006 2422.19)
'(785770.0 9.28376e+006 2422.24)
'(785765.0 9.28376e+006 2422.47)
'(785765.0 9.28376e+006 2422.47)
'(785765.0 9.28376e+006 2422.47)
'(785765.0 9.28376e+006 2422.47)
'(785765.0 9.28376e+006 2422.47)
'(785765.0 9.28376e+006 2422.47)
'(785765.0 9.28376e+006 2422.47)
'(785765.0 9.28376e+006 2422.47)
'(785762.0 9.28377e+006 2422.77)
'(785763.0 9.28377e+006 2422.91)
))

It is clear that my common point is

 

(785765.0 9.28376e+006 2422.47)

 

How can I get it from the LIST.?

 

Are you asking how to extract the point in the list that has duplicates?

Posted
Are you asking how to extract the point in the list that has duplicates?

 

Yes , because it hold the Z value , just over the block

 

(setq ins-pt '(785765.0 9.28376e+006 0.0) )

Ins-pt is the insertion point of the block , so by

 

(setq ent-ss (ssget "_c" ins-pt ins-pt '((0 . "LINE") )))

I got all the lines that match it's code 10 or code 11 at such point.

 

Now I get all code 10 and 11 , only the repeated value hold the Z over the block's insertion point

 

I tried with

 

(ssget "_c"
           INS-PT
           INS-PT
           (list '(0 . "LINE")
             '(-4 . "<or")
             '(-4 . "=,=,*")
             (cons 10 INS-PT)
             '(-4 . "=,=,*")
             (cons 11 INS-PT)
             '(-4 . "or>")))
 

Given the * as wildcard for any Z value , but it did not work.

 

See the Sample DWG ,

 

So I got all code 10 and 11 from each line , then sort it by it's Z value , an got the LIST with the repeated and not repeated points.

The repeated , hold the Z value over the block's insertion point

to get the z over the block.dwg

Posted

Call it a first draft, it will only return 1 duplicate...

 

[color=Yellow](defun DuplicatePoint (#List / #New #Dup)
 (foreach x #List
   (if (member x #New)
     (setq #Dup x)
     (setq #New (cons x #New))
   ) ;_ if
 ) ;_ foreach
 #Dup
) ;_ defun[/color]

**UPDATE: Much better one posted here:

http://www.cadtutor.net/forum/showpost.php?p=280056&postcount=12

I'll leave the original up for posterity. :)

Posted

This might also help:

 

;;; Remove all duplicates from list
;;; #List - List to process
;;; Alan J. Thompson, 04.21.09
(defun AT:ListNoDuplicates (#List / #New)
 (foreach x #List
   (or (vl-position x #New) (setq #New (cons x #New)))
 ) ;_ foreach
 (reverse #New)
) ;_ defun

Posted
It work as I need to be .

Thanks

No problem. :)

Posted

This one is like the

REMOVE-DUPS I use , it is not the case , It remove , but do not show wich one is the duplicate.

 

Thanks

Posted
This one is like the

REMOVE-DUPS I use , it is not the case , It remove , but do not show wich one is the duplicate.

 

Thanks

I know that. I was just offering another list duplicate example.

Posted
Thanks.I appreciate it .

:)

No problem. I assume you figured everything out.

Posted

Thought about this over dinner...

 

;;; Return all all duplicates within list
;;; #List - List to process
;;; Alan J. Thompson, 11.01.09
(defun AT:ListDuplicates (#List)
 (vl-remove-if-not
   '(lambda (x) (member x (cdr (member x #List))))
   #List
 ) ;_ vl-remove-if-not
) ;_ defun

 

Will return all duplicates. :)

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