Find and Replace work around

Find and Replace work around

Anonymous
Not applicable
1,335 Views
14 Replies
Message 1 of 15

Find and Replace work around

Anonymous
Not applicable

I am trying to come up with a work around for searching drawings. I need to either search 2 or more attributes value (Part "C4" & Length "11'-0"") at once or search fields (ZZZ attribute).

 

Attached is the file I am currently checking.

My piece-marks are dynamic blocks with attributes used for the data extraction.

Capture1.JPGI am checking this drawing for accuracy and want to find all the (C4)11'-0" occurrences. The mark has attributes for C4 and 11'-0". I can find either but not both at the same time. I have an attribute with fields (ZZZ) that pulls all this information into the actual mark (C4)11'-0". That attribute has fields in it and is not searchable.

Capture2.JPGIf I run my field to text lisp I can search exactly what I need but then I lose the functionality of the fields in that attribute.

 

This is why I am trying to figure out a way to search attribute content for both C4 and 11'-0", so I don't have to run the lisp, find and replace then undo back before the lisp. Just trying to streamline the work flow.

 

Any thoughts on how to accomplish this would be appreciated.

 

Thank you.

Daryl

0 Likes
Accepted solutions (4)
1,336 Views
14 Replies
Replies (14)
Message 2 of 15

ronjonp
Mentor
Mentor

Here's a quick one to highlight those blocks:

(defun c:foo (/ _ga o r s)
  (defun _ga (b tag)
    (vl-some
      '(lambda (att)
	 (cond
	   ((= (strcase tag) (strcase (vla-get-tagstring att))) (strcase (vla-get-textstring att)))
	 )
       )
      (vlax-invoke b 'getattributes)
    )
  )
  (cond	((setq s (ssget "_a" '((0 . "insert") (66 . 1))))
	 (setq r (ssadd))
	 (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	   (setq o (vlax-ename->vla-object x))
	   (and (= "C4" (_ga o "Part")) (= "11'-0\"" (_ga o "Length")) (ssadd x r))
	 )
	 (sssetfirst nil r)
	)
  )
  (princ)
)
Message 3 of 15

Anonymous
Not applicable

That is a good start to what I need to do. I need to be able to change the search as well though. Such as (C435)11'-0" or (C4)13'-6". This would be used in checking these drawings all of which have multiple part and length call outs.

What I would like to do is similar to the find and replace. Be able to change the values searched for. Those are the only two attributes I would need to search regularly at the same time.

0 Likes
Message 4 of 15

ronjonp
Mentor
Mentor
Accepted solution

This will let you enter the values to check:

(defun c:foo (/ _ga o r s s1 s2)
  (defun _ga (b tag)
    (vl-some
      '(lambda (att)
	 (cond
	   ((= (strcase tag) (strcase (vla-get-tagstring att))) (strcase (vla-get-textstring att)))
	 )
       )
      (vlax-invoke b 'getattributes)
    )
  )
  (cond	((and (setq s1 (getstring "\nEnter PART string to search: "))
	      (setq s2 (getstring "\nEnter LENGTH string to search: "))
	      (setq s (ssget "_a" '((0 . "insert") (66 . 1))))
	 )
	 (setq r (ssadd))
	 (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	   (setq o (vlax-ename->vla-object x))
	   (and (= (strcase s1) (_ga o "Part")) (= (strcase s2) (_ga o "Length")) (ssadd x r))
	 )
	 (sssetfirst nil r)
	)
  )
  (princ)
)
0 Likes
Message 5 of 15

Anonymous
Not applicable

NICE! 

Thank you!

0 Likes
Message 6 of 15

ronjonp
Mentor
Mentor

You're welcome!

0 Likes
Message 7 of 15

Anonymous
Not applicable

This was working great last week but now when I go to type in the length I cannot use the space bar or it thinks I have hit enter?  It wont let me enter lengths as 10'-11 3/4". It is great with lengths without fractions.

0 Likes
Message 8 of 15

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....  It wont let me enter lengths as 10'-11 3/4". ....


 

The way to do that is to use no  hyphen between the feet mark and the inches number, and put the hyphen between the inches and the fraction:

10'11-3/4

 

[with or without the inches mark].  It's a peculiarity resulting from the fact that, by convention in displayed  distance values such as Dimensions, as in the hand-drafted convention, there's a hyphen between feet and inches, and a space between inches and fractions if the fraction isn't stacked, but when typing in  such a value, spaces cause exactly the trouble you describe.

 

It's always been that way, though I haven't been able to quickly find where it's described in Help.  [If anywhere -- it certainly was long ago, because that's how I knew about it, but the whole structure of Help has changed several times since then, and finding some kinds of things can be difficult.  Help for UNITMODE at least shows that you have the option of which way to display  such values, and says you can't type them in with spaces, but doesn't tell you how to do it.]

Kent Cooper, AIA
0 Likes
Message 9 of 15

Anonymous
Not applicable

I gotcha.

Thank you for the explanation. That's a bit of a bummer, I was loving this lisp.

I cannot change my piecemarks to make that work as we need the current format to upload into our ERP system. Guess I will just have to keep working around as best I can.

0 Likes
Message 10 of 15

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

.... I cannot change my piecemarks to make that work as we need the current format to upload into our ERP system. Guess I will just have to keep working around as best I can.


 

I hadn't dug into the code you were doing this in, but if it's @ronjonp's latest, and if the problem is in this part:

 

       (setq s2 (getstring "\nEnter LENGTH string to search: "))

 

and if you're really entering it as a text string value  which will be the content of an Attribute it's looking for, not for its actual numerical equivalent, then you can get (getstring) to allow spaces in your input, with the optional [cr] argument to require Enter [= carriage return] to complete the input:

 

       (setq s2 (getstring T "\nEnter LENGTH string to search: "))

Kent Cooper, AIA
0 Likes
Message 11 of 15

Anonymous
Not applicable

Sweet! That works perfectly.

 

Thank you all so much for the help with this.

0 Likes
Message 12 of 15

dbhunia
Advisor
Advisor
Accepted solution

@Anonymous wrote:

This was working great last week but now when I go to type in the length I cannot use the space bar or it thinks I have hit enter?  It wont let me enter lengths as 10'-11 3/4". It is great with lengths without fractions.


 

Simply use "T" to feed "space Bar"  as your input in @ronjonp code......

 

......................
  (cond	((and (setq s1 (getstring T  "\nEnter PART string to search: "))
	      (setq s2 (getstring T "\nEnter LENGTH string to search: "))
	      (setq s (ssget "_a" '((0 . "insert") (66 . 1))))
	 )
......................

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 13 of 15

Anonymous
Not applicable

This has been working perfectly for me. Thank you to all who helped build this.

 

One question I have now is, is there a way I could get it to zoom to the selection?

0 Likes
Message 14 of 15

dbhunia
Advisor
Advisor
Accepted solution

Try this.......

 

(defun c:PM (/ _ga o r s s1 s2)
  (defun _ga (b tag)
    (vl-some
      '(lambda (att)
	 (cond
	   ((= (strcase tag) (strcase (vla-get-tagstring att))) (strcase (vla-get-textstring att)))
	 )
       )
      (vlax-invoke b 'getattributes)
    )
  )
  (cond	((and (setq s1 (getstring "\nEnter PART string to search: "))
	       (setq s2 (getstring T "\nEnter LENGTH string to search: "))
	      (setq s (ssget "_a" '((0 . "insert") (66 . 1))))
	 )
	 (setq r (ssadd))
	 (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	   (setq o (vlax-ename->vla-object x))
	   (and (= (strcase s1) (_ga o "Part")) (= (strcase s2) (_ga o "Length")) (ssadd x r))
	 )
	 (command "_.zoom" "o" r "")
	 (sssetfirst nil r)
	)
  )
(princ)
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 15 of 15

Anonymous
Not applicable

PERFECT! Thank you so much.

0 Likes