Visual LISP, AutoLISP and General Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
ssget by coordinate s
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
i am working on writing a lisp to update several similar drawings through a .bat file. One of the things i would like to do is to automtaically increase the revision number by one. I have figured out everything except how to select the text. Looking at the database, the coordinates for the revision number are (10 15.2908 0.0295 0.0). However, (setq a (ssget "x" '((0 . "TEXT,MTEXT")(10 15.2908 0.0295 0.0)))) returns nil.
Are the database coordinate values not precice enough? If so, how can I determine what the actual coordinatea are?
If each drawing's revision number is not in the exact same location, is it possible to select by a range of coordinates? Using (getpoint), the range is from (15.5 0.0 0.0) to (15.1805 0.1409 0.0).
Solved! Go to Solution.
Re: ssget by coordinate s
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Assuming that there is only one element to your selection set this might get you started.
(setq cnt 1)
(setq ss1 (ssget "c" '(15.5 0.0) '(15.1805 0.1409)))
(setq ent1 (entget (ssname ss1 0))
revno (cdr (assoc 1 ent1))
(setq new (cons 1 (itoa (+ (atoi revno) cnt)))
old (assoc 1 ent1)
ent1 (subst new old ent1))
(entmod ent1)
southie
Re: ssget by coordinate s
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
oops should have been
(setq cnt 1)
(setq ss1 (ssget "c" '(15.5 0.0) '(15.1805 0.1409)))
(setq ent1 (entget (ssname ss1 0))
revno (cdr (assoc 1 ent1))
(setq new (cons 1 (itoa (+ (atoi revno) cnt)))
old (assoc 1 ent1)
ent77 (subst new old ent1))
(entmod ent77)
Re: ssget by coordinate s
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Very fat fingured today.
should have been
(setq cnt 1)
(setq ss1 (ssget "c" '(15.5 0.0) '(15.1805 0.1409)))
(setq ent1 (entget (ssname ss1 0))
revno (cdr (assoc 1 ent1))
);setq
(setq new (cons 1 (itoa (+ (atoi revno) cnt)))
old (assoc 1 ent1)
ent77 (subst new old ent1))
(entmod ent77)
Re: ssget by coordinate s
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
southie wrote:Very fat fingured today.
should have been
(setq cnt 1)
(setq ss1 (ssget "c" '(15.5 0.0) '(15.1805 0.1409)))
(setq ent1 (entget (ssname ss1 0))
revno (cdr (assoc 1 ent1))
);setq
(setq new (cons 1 (itoa (+ (atoi revno) cnt)))
old (assoc 1 ent1)
ent77 (subst new old ent1))
(entmod ent77)
(setq ss1 (ssget "c" '(15.5 0.0) '(15.1805 0.1409)))
(setq ent1 (entget (ssname ss1 0)))
(setq revno (cdr (assoc 1 ent1)))
(setq new (cons 1 (itoa (+ (atoi revno) cnt))))
(setq old (assoc 1 ent1) )
(setq ent77 (subst new old ent1))
(entmod ent77)
very nice, thanks. much more simple than the way i wrote it:
(setq a (ssget "c" '(15.5 0.0) '(15.1805 0.1409)))
(setq b (cdr (assoc 1 a)))
(setq c (atoi b))
(setq d (+ 1 c))
(setq e (itoa d))
(setq a (subst (cons 1 e) (assoc 1 a) a))
(entmod a)
Re: ssget by coordinate s
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
michael.deleurere wrote:....(setq ss1 (ssget "c" '(15.5 0.0) '(15.1805 0.1409)))
....
You might consider a little adjustment. Because not all numbers "touch" their insertion points, that way of looking for them might miss them sometimes. In the left-justified situation in the attached image,
(ssget "C" '(0 0 0) '(1 1 0))
returns nil, though the insertion point is right in the middle of the window it's looking at. The possibility of any problem will vary with size of your positional range in relation to the text size, and/or with the justification and the text characters involved, but given the "wrong" relationship, you could have the same happen with, say, a middle-justified 11, etc., etc.
You could either use a larger Crossing window, as long as you limit its size to eliminate the risk of catching some unwanted object(s) in addition to the desired one, such as Line parts of a title block. Or you could determine the coordinates of a [non-crossing] Window that will always include the whole number, its size depending on how many characters it's ever likely to reach.
Re: ssget by coordinate s
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Re: ssget by coordinate s
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
michael.deleurere wrote:
(setq ss1 (ssget "c" '(15.5 0.0) '(15.1805 0.1409)))
(setq ent1 (entget (ssname ss1 0)))
(setq revno (cdr (assoc 1 ent1)))
(setq new (cons 1 (itoa (+ (atoi revno) cnt))))
(setq old (assoc 1 ent1) )
(setq ent77 (subst new old ent1))
(entmod ent77)
I guess you dont realize you can add a filter with (ssget "C" ...)
(setq ss1 (ssget "c" '(15.5 0.0) '(15.1805 0.1409)'((0 . "TEXT,MTEXT")(1 . "#*"))))
you can even throw in a layer/height/color etc.... that way you can increase the size of the window without the risk of catching some unwanted object(s)
HTH
Re: ssget by coordinate s
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
stevor wrote:
And you may have to zoom to the coordinates, or a zoom all.
Hang on, stevo raised a good point there.
perhaps we can still use ssget "X"
(setq ss1 (ssget "_X" '((0 . "TEXT,MTEXT")(1 . "#*") (-4 . "<AND") (-4 . ">=,<=,*")(10 15.1805 0.1409 0.0) (-4 . "<=,>=,*")(10 15.5 0.0 0.0) (-4 . "AND>"))))
You may need to add DXF 410 in there
HTH
Re: ssget by coordinate s
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
so far, i am still testing on the first drawing and
(setq ss1 (ssget "c" '(15.5 0.0) '(15.1805 0.1409)))
works fine. those coordinates represent the box on the border in which the revision number lies. Once testing begins on a series of drawings, it may have to be further refined.
one other issue i have run into: apart from chaning the revision number, there is also a place for a revision number/ description on the title block. i have created a seperate drawing with the revision description which will insert as a block to specific coordinates based on the newly changed number from this:
(setq new (cons 1 (itoa (+ (atoi revno) cnt))))
the revision description block drawing shows a revision number of 0, which will then get added to by (setq cnt #)
using the original code, i have set up a conditional statement as follows:
(cond
((= new 2)
(command "-insert" "revd.dwg" "8.9076,0.2496" "1" "1" "0")
(command "explode" "last")
(command "-purge" "block" "rev" "n")
(setq cnt 2)
(setq ss1 (ssget "c" '(8.9076 0.624) '(9.188 0.4992)))
(setq ent1 (entget (ssname ss1 0)))
(setq revno (cdr (assoc 1 ent1)))
(setq new (cons 1 (itoa (+ (atoi revno) cnt))))
(setq old (assoc 1 ent1))
(setq ent77 (subst new old ent1))
(entmod ent77)
);end condition
((= new 3)
(command "-insert" "rev.dwg" "8.9076,0.3744" "1" "1" "0")
(command "explode" "last")
(command "-purge" "block" "rev" "n")
(setq cnt 3)
(setq ss1 (ssget "c" '(8.9076 0.4992) '(9.188 0.3744)))
(setq ent1 (entget (ssname ss1 0)))
(setq revno (cdr (assoc 1 ent1)))
(setq new (cons 1 (itoa (+ (atoi revno) cnt))))
(setq old (assoc 1 ent1))
(setq ent77 (subst new old ent1))
(entmod ent77)
);end condition
);end cond.
however, both of these return nil. i have also tried ((= new "3")... but that returns also returns nil.
since running the statement without conditionals works fine, the problem is the cond statment is not reading the value of "new". how can i get the conditional to recognize the new revision number?


