Jump to content

Recommended Posts

Posted

Hi all,

 

I'm looking for a way to check my BOM lines (mostly copied from multiple drawings) for duplicate part numbers (all number, no alphabets but might have - or _) in an attribute block with a tag named DESCRIPTION & SAPNUMBERS.

 

Example

 

If the description says 12345 in one line and if the same is found on the another line in the description column then thats duplicate. Similarly on the SAPNUMBER column as well. If one of these return true then I will evaluate both the lines manually.

 

Dont want to delete anything here. Just want to make sure I dont have same line repeated twice on the BOM. If found, I will just adjust the qty and delete one. Thats manual work that I do.

 

Does anyone have any utility that I can use?

 

Thank you.

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • shailujp

    12

  • pBe

    9

Top Posters In This Topic

Posted Images

Posted

Nop. each BOM line is one attribute block and same is copied multiple times to make complete BOM.

Posted

So how do you propose to show the duplicates then?

Posted

May be highlight two entities. In most cases there are only couple of duplicates. If all duplicated are highlighted, it wont be difficult to work thru the selection. Do you have any better idea?

Posted

We want to see what you have to start with. drawing file that is.

Posted

I have attached a sample file. I'm sorry I not very clear on your question though. Is this what you were looking for?

Duplicate check.dwg

Posted (edited)

No time to wait for your sample

 

Code removed [refer to post # 14]

Edited by pBe
Posted

pBe,

 

Works wonderfully well. Your lisp draws lines between two duplicate is a much better option. Thank you very much

 

Edit: I got the tag name SAPNUMBERS incorrect on the sample file. I have fixed it on my pc.

Posted

The updated code draws a rectangle. you can do the rest like creating a layer for the rectangles and what not.

Posted

I'm going to try myself to include drawing number check myself from your lisp. Appriciate your help.

Posted

Rectangle doesnt give any idea of which is duplicate with which one and numbers become difficult to visualize. Where as lines end points makes it very clear. I'm keeping the line concept.

Posted

Hi pBe,

 

I just found that the blanks entries are also considered as duplicates. Can this be avoided? See attached snap.

 

Also, how to get the princ for each item?

Ex. No duplicates found on Description

or No duplicates found on Drawing_Number etc...

 

And I was able to include Drawing_number check as well. That was easy.

Capture.PNG

Posted
Hi pBe,

 

I just found that the blanks entries are also considered as duplicates. Can this be avoided? See attached snap.

 

Also, how to get the princ for each item?

Ex. No duplicates found on Description

or No duplicates found on Drawing_Number etc...

 

And I was able to include Drawing_number check as well. That was easy.

 

What i was thinking was, iclude colros for duplicates, say there are 5 "12345" all of them would be "boxed" with the same color. would you want that?

 

as for the "" blank items its an easy modification.

Posted

After bit of trials, I found that lines work well and becomes very easy to remove as well. Its a great idea to color the boxes but considering the very limited instances of duplicates, it may not be that useful and also makes difficult to visualize the numbers. But it may be very usefull if the large data and more number of duplicates.

 

For now, I think just the blank line issue is just need to resolved.

 

Btw, I have already caught few duplicates on my drawings and saved my A...

Posted (edited)

Well ok then,

 

Now FWIW

 

(defun c:LTD (/ LWPoly _dupl ssD data);LineToDuplicate
(defun _ftf (pt m)
 	(polar pt (if m (* pi 0.25) (* pi 1.25))(* 0.05 (sqrt 2))))

 (defun LWPoly	(lst clr)
   (foreach att lst
     (vla-getboundingbox att 'mn 'mx)
     (setq p1 (_ftf (vlax-safearray->list mn) nil)
           p3 (_ftf (vlax-safearray->list mx) t)
           p2 (list (car p1)(cadr p3) 0.0)
    p4 (list (car p3)(cadr p1) 0.0))
(entmakex
     (append (list (cons 0 "LWPOLYLINE")
	    (cons 100 "AcDbEntity")
	    (cons 100 "AcDbPolyline")
	    (cons 8 "DuplicateLine")
	    (cons 62 clr)
	    (cons 70 1)
	    (cons 90 (length (setq lst (list p1 p2 p3 p4 p1))))
				   )
      (mapcar (function (lambda (p) (cons 10 p))) lst)
     			)
   		)	
)
)
(Defun _numb (str)
 (vl-list->string
   (vl-remove-if-not
     '(lambda (n)
 (< 47 n 58)
      )
     (vl-string->list str)
   )
 )
)
(defun _dupl (itm  / a b c d e f)
(while (setq a (Car itm))
(setq b	 (cdr itm) id (car a))
(while (setq d (assoc id b))
  (setq	e (cons d e)
	b (vl-remove d b)))
(if e
  (setq f (cons (cons a e) f)))
(setq itm b e nil)
)
 f)
 (if (setq data nil ssD (ssget "_X" (list
			       '(0 . "INSERT")
		      	'(2 . "BOM_LINE*")
			       '(66 . 1)
			       (cons 410 (getvar 'ctab)))))
   (progn
   	(repeat (setq i (sslength ssd))
  (setq data (cons 
  	(mapcar	(function (lambda (l)
			    (list (vla-get-tagstring l)
				  (_numb (vla-get-textstring l))
				  l
			    )
			  )
		)
		(vlax-invoke
		  (vlax-ename->vla-object
		    (ssname ssd (setq i (1- i)))
		  )
		  'GetAttributes
		)
	) data))
  )
     (setq data (apply 'append data))
     (foreach itm '("DESCRIPTION" "SAPNUMBER")
	(set (setq df (Read itm))
	     (vl-remove-if-not '(lambda (l)
				  (and (eq (car l) itm)
				       (/= (cadr l) ""))) data))
)
     (setq col 0)
     (foreach itm 
(setq des (_dupl (mapcar 'cdr DESCRIPTION)))
(print (caar itm))
(setq col (1+ col))
(LWPoly (mapcar 'cadr itm) col)
)
     (foreach itm (setq sap (_dupl (mapcar 'cdr SAPNUMBER)))
(print (caar itm))
(setq col (1+ col))
(LWPoly (mapcar 'cadr itm) col)
     )
     )
     
)
   (princ (cond
     ((null ssd) "\nNo valid selection")
     ((and (null des)
	  (null sap)) "\nNo Duplicates Found")))
 (princ)
)

Edited by pBe
updated again
Posted

pBe,

 

This one is much better. After a couple of trial, I learned that it looks for a whole text line and compares with another and not just numbers. For SAP numbers, this is a perfect way. However for the description, since the desc. is written manually, there are chances that user may have written differently or may have abbriviated it. The only constant is a part number that dont change (ie. 12345). So, I just tweaked desc. and ran it again and this time result changed.

 

But, aleast SAP number is catching the duplicate even if the desc. is messed-up. So I have one or both places to catch the error and one is enough to pay attention to the whole line.

 

I thank you for the effort you have taken to help me thru this.

 

Regards.

 

I'm creating a small routing that will erase all entities on the Duplicateline layer. That way I dont have to erase it manually.

Capture.PNG

Posted

So do you still need help in tweaking the code? or you can handle this on your own?

 

As for the Description tag, as long as the # sign its an easy modification.

Posted

# sign is not consistant between drawings. I have also included the Drawing_Number tag in it. So I have now 3 levels of checks which should be enough to catch error.

 

I have made this code to erase entities and purge Duplicateline layer.

 

 

 
(defun c:DUPL (/ erdup)
               (if 
    (tblsearch "LAYER" "DuplicateLine")    
   (if (setq erdup (ssget "_x" '((8 . "DuplicateLine"))))
      (progn
              (command "erase" erdup "")
               (Command "-Purge" "la" "DuplicateLine" "n")
     );end progn
         ); end if2
   (princ "\nLayer not found")
               ); end if1
); end defun

Posted (edited)
# sign is not consistant between drawings. I have also included the Drawing_Number tag in it. So I have now 3 levels of checks which should be enough to catch error.

 

Glad you had it sorted.

 

post updated to consider "X XX #1234"

Edited by pBe

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