DuanJinHui Posted April 24, 2017 Posted April 24, 2017 How compare 2 obj ? if the same ,return T , not same , return nil Quote
Roy_043 Posted April 24, 2017 Posted April 24, 2017 Since every object has a unique handle property, strictly speaking, identical objects do no exist... First compare the objectname property of the two objects. If they have the same object name: Use the atoms-family function to get a list of all functions. Filter for "vla-get-*" functions and compile a list of all properties (skip the handle property). Check which properties are available (vlax-property-available-p) for the objects and compare values. Perhaps use vl-every to do so efficiently. Quote
BIGAL Posted April 25, 2017 Posted April 25, 2017 Like Roy_043 some of the obvious line,arc,circle,pline layer, length,area you need to provide more information about what you are comparing, solids are different again. Quote
Roy_043 Posted April 25, 2017 Posted April 25, 2017 In its simplest, most primitive, form the function could look like this: ; (CompareEntities_P (car (entsel)) (car (entsel))) (defun CompareEntities_P (enm1 enm2 / elst1 elst2) (setq elst1 (entget enm1)) (setq elst2 (entget enm2)) (and (= (length elst1) (length elst2)) (vl-every '(lambda (sub1 sub2) (cond ((/= (car sub1) (car sub2)) nil ) ((vl-position (car sub1) '(-1 5)) ; Skip ename and handle. T ) (T (equal sub1 sub2 1e- ) ) ) elst1 elst2 ) ) ) Quote
Lee Mac Posted April 25, 2017 Posted April 25, 2017 This example may offer some ideas - the example demonstrates a possible method of selecting blocks with similar geometry, but the idea could be translated to primary objects. Quote
Roy_043 Posted April 25, 2017 Posted April 25, 2017 @Lee: Interesting solution, but with a chance of false positives. Quote
Lee Mac Posted April 25, 2017 Posted April 25, 2017 @Lee:Interesting solution, but with a chance of false positives. Thanks Roy, though a stricter comparison may miss valid results - this form of function is notoriously ambiguous. Quote
DuanJinHui Posted April 26, 2017 Author Posted April 26, 2017 In its simplest, most primitive, form the function could look like this: ; (CompareEntities_P (car (entsel)) (car (entsel))) (defun CompareEntities_P (enm1 enm2 / elst1 elst2) (setq elst1 (entget enm1)) (setq elst2 (entget enm2)) (and (= (length elst1) (length elst2)) (vl-every '(lambda (sub1 sub2) (cond ((/= (car sub1) (car sub2)) nil ) ((vl-position (car sub1) '(-1 5)) ; Skip ename and handle. T ) (T (equal sub1 sub2 1e- ) ) ) elst1 elst2 ) ) ) Thank you Roy, Quote
Recommended Posts
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.