Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

record boundary label routine

11 REPLIES 11
Reply
Message 1 of 12
gnarlytreeman
253 Views, 11 Replies

record boundary label routine

ok here is the problem i'm having, i've got some malformed selectionset call, and i'm having problems getting the string operations to work with other than just TEXT objects, if someone could kinda point me in the right direction that would be great, i need this lisp for daily drafting for a surveying division.


(defun C:deed()
(setvar "cmdecho" 0)
(repeat 100
(setq newsty L80)
(setq sset(ssget '((-4 . ""))))
(setq numb -1)
(repeat (sslength sset)
(setq numb(1+ numb))
(setq obj(entget(ssname sset numb)))
(setq obj(subst (cons 7 newsty) (assoc 7 obj) obj))
(setq en obj)
(command "_.change" obj "P" "C" "cyan" "")
(entmod obj)
(if (setq en(car(entsel)))
(progn
(setq enlist(entget en))(cdr(assoc 0 enlist)))
(progn
(setq str(strcat "("(cdr(assoc 1 enlist)) ")"))
(setq enlist(subst (cons 1 str)(assoc 1 enlist) enlist))
(entmod enlist)
))
(setvar "cmdecho" 1)
))) Message was edited by: gnarlytreeman
11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: gnarlytreeman

Your ssget is the wrong syntax. If your trying to get the user to select text it should look something like...
(setq sset (ssget '((0 . "TEXT"))))

That's just the first problem. What is this routine suppose to do exactly?
Message 3 of 12

well i need it to pick up text and mtext objects, then take them modify the text style, flop to a different layer, and add parenthesis around them.

(defun C:deed(/ newsty sset numb obj en enlist)
(setvar "cmdecho" 0)
;; repeat the commad for continuois editing

(repeat 100

;; newsty is set to string l80 for imput later

(setq newsty L80)

;; selection set of objects
(setq sset(ssget '((-4 . ""))))
(setq numb -1)
(repeat (sslength sset)
(setq numb(1+ numb))
;; object single edit pick instance
(setq obj(entget(ssname sset numb)))
;;object change functions for style and layer changes
(setq obj(subst (cons 7 newsty) (assoc 7 obj) obj))
;; set en variable to be same as obj variable
(setq en obj)
(command "_.change" obj "P" "C" "cyan" "")
(entmod obj)

;; string portions of code to add the parenthesis into the text

(if (setq en(car(entsel)))
(progn
(setq enlist(entget en))(cdr(assoc 0 enlist)))
(progn
(setq str(strcat "("(cdr(assoc 1 enlist)) ")"))
(setq enlist(subst (cons 1 str)(assoc 1 enlist) enlist))
(entmod enlist)
))
(setvar "cmdecho" 1)
))) null
Message 4 of 12
Anonymous
in reply to: gnarlytreeman

Okay, I think all you need to do is...
1) create a selection set with ssget and use a filter to get text and mtext objects.
(setq sset (ssget '((0 . "TEXT,MTEXT"))))
2) go through each entity in the set using your REPEAT function and change the layer, color, style and text just like you are doing with the SUBST function

Here's some thoughts.

(repeat 100;<-- I don't think you need this.

(setq sset (ssget '((0 . "TEXT,MTEXT"))));<-- This will allow the user to select any text and mtext objects.

(command "_.change" obj "P" "C" "cyan" "");<-- use could use subst instead of a command here. Modify the dxf code 62 just like you did with the style. 4 is the number for color "cyan"
(setq obj(subst (cons 62 4) (assoc 62 obj) obj))


(if (setq en(car(entsel)));<-- you don't need to pick anything again, you are already going through your selection set. Just modify the dxf code 1 of the variable obj.

Hope this helps. I just going off the cuff here. I haven't tested anything but this should give you some ideas. Don't be afraid to ask any questions.
Message 5 of 12

cool thanks man i'll check out what i can hack together and repost it.

actually the repeat 100 is so you don't exit the command after running one time, an extra enter exits you out, it's just a handy part of code i've been using to keep the keys down for production drafting, cause usually you want to use the same command more than once when you que it
Message 6 of 12

okie here's what i've got now, and i've narrowed the problem, in order to use the dxf code to mobify the enteties i need to get a list and write and if text or if mtext for each step of modification because the dxf codes are different for each entity, if i can find out where to get the dxf codes lists for different object this would go quicly from here on.

but anyways here's my current code

(defun C:deed(/ newsty sset numb obj dxfobjlist)
(setvar "cmdecho" 0)

;; newsty is set to string l80 for imput later

(setq newsty L80)

;; selection set of objects

(setq sset (ssget '((0 . "TEXT,MTEXT"))))
(setq numb -1)
(repeat (sslength sset)
(setq numb(1+ numb))

;; object single edit pick instance

(setq obj(entget(ssname sset numb)))

;;object change functions for style L80 and Color Cyan changes

(setq obj(subst (cons 7 newsty) (assoc 7 obj) obj))
;; need and if text if mtext here
(setq obj(subst (cons 62 4) (assoc 62 obj)obj))
;; and another one here

;; string portions of code to add the parenthesis into the text

(progn (setq dxfobjlist(entget obj))

(if (= "TEXT" (cdr(assoc 0 dxfobjlist)))
(progn (setq str(strcat "("(cdr(assoc 1 dxfobjlist)) ")"))
(setq dxfobjlist(subst (cons 1 str)(assoc 1 dxfobjlist) dxfobjlist))
(entmod dxfobjlist)))

(if (= "MTEXT" (cdr(assoc 0 dxfobjlist)))
(progn (setq str(strcat "("(cdr(assoc 1 dxfobjlist)) ")"))
(setq dxfobjlist(subst (cons 1 str)(assoc 1 dxfobjlist) dxfobjlist))
(entmod dxfobjlist)))

(entmod dxfobjlist)
))
(entmod obj)
(setvar "cmdecho" 1)
))
Message 7 of 12

i'm gonna learn a bit about visual lisp instead of using dxf codes, this will be cake to write with the visual lisp object properties calls.
Message 8 of 12
Anonymous
in reply to: gnarlytreeman

Hey gnarly,
busy yesterday, but i'll have a chance later this afternoon to take a look at your code.
Question: do you use the VLIDE to write your code?
Message 9 of 12
Anonymous
in reply to: gnarlytreeman

(defun C:deed(/ newsty sset numb obj dxfobjlist)
(setvar "cmdecho" 0)

;; newsty is set to string l80 for imput later

;;;be careful here, newsty must be a style that exists and
;;;is also a string value like "L80"
(setq newsty "L80")

;; selection set of objects

(setq sset (ssget '((0 . "TEXT,MTEXT"))))
(setq numb -1)
(repeat (sslength sset)
(setq numb(1+ numb))

;;;(setq obj(entget(ssname sset numb)))

;;;the best thing to do is get the entity name, then the entity list
(setq obj (ssname sset numb));<- entity name
(setq dxfobjlist (entget obj));<-entity dxflist

(setq dxfobjlist (subst (cons 7 newsty) (assoc 7 dxfobjlist) dxfobjlist))
;; need and if text if mtext here
(setq dxfobjlist (subst (cons 62 4) (assoc 62 dxfobjlist) dxfobjlist))
;; and another one here

;;;(progn (setq dxfobjlist(entget obj));<-- this is already a dxf object list,
;;;entget will give error
;;;also, don't need a progn

;;;These IF statements work fine. But, you could combine them together
;;;into one IF statement. Since everything in your selection set is
;;;either TEXT or MTEXT
(if (= "TEXT" (cdr(assoc 0 dxfobjlist)))
;then statement
(progn
(setq str(strcat "("(cdr(assoc 1 dxfobjlist)) ")"))
(setq dxfobjlist(subst (cons 1 str)(assoc 1 dxfobjlist) dxfobjlist))
(entmod dxfobjlist)
)
;;; )

;;; (if (= "MTEXT" (cdr(assoc 0 dxfobjlist)))

;else statement
(progn
(setq str(strcat "("(cdr(assoc 1 dxfobjlist)) ")"))
(setq dxfobjlist(subst (cons 1 str)(assoc 1 dxfobjlist) dxfobjlist))
(entmod dxfobjlist)
)
)
;;;after you ENTMOD the dxf list
;;;you ENTUPD the entity name
;;;(entmod dxfobjlist);<-- already done
(entupd obj);entity update

;(entmod obj);<-- already done,

(setvar "cmdecho" 1)
)
)

You might have to change the color change back to the command function since it won't work with mtext. Also, you can find a list of the DXF codes in Help...Developer Help, DXF Reference.
Message 10 of 12

no i don't use vlide to write code, i mostly program by hand and look at other stuff for examples, then update all the variables to something i can understand what they are and check a few websites for better functions to use, and maybe get a good handle on the best way to write the code, most effective given the situation, then set it in stone.

k i'm gonna go thru the code again, i downloaded a cpoy of the vlisp dev bible for free online from a wikki site, i think i'm gonna read thru that a bit and add the entity color changes with some of that, because it can just grab any entity and change it for me which would be nice.
Message 11 of 12
Anonymous
in reply to: gnarlytreeman

Yep, using vlisp is probably the way to go. I have to admit, I'm not as familar with vlisp stuff as I would like to be. I just downloaded a vlisp guide by David M Stein. Is that the one you're looking at?
Just looking at it, you probably what something like:
(setq objText (vlax-ename->vla-object ent))
then
(vla-put-color objText "CYAN")
Message 12 of 12

yeah thats the one i have i think, but i think i'm gonna sit down and read it cover to cover before i start with the stuff

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost