Jump to content

Filter textcontent and place in layer


OMEGA-ThundeR

Recommended Posts

Hello,

 

i got an GPS Survey readout and i use some program to translate it to an autocad drawing.

 

Problem in this is that the conversion places everything (insertion point and some mtext labels) in the layer 0.

 

With the 'Qselect' command i can filter certain textcontents and select all the labels with a certain content and place it in a layer, in the end i can filter objects by layer this way.

 

This however is time consuming, so i would like to make some sort of LISP that does this in an automated way.

 

FILTER and QSELECT don't have command line commands, so they are out of the question for lisp, but the internet said something about SSGET

 

(ssget "_X" '((0 . "TEXT,MTEXT")(1 . "A*,B*")))

source: http://www.cadforum.cz/cadforum_en/qaID.asp?tip=6403

 

The content of text in the labels is something like:

 

Huisaansluiting - DWA,Inlaat

Huisaansluiting - HWA,Inlaat

Kolken,Trottoirkolk

Kolken,Inlaat

 

 

Lets take the last one for example "Kolken,Inlaat" and then i use the following code:

 

;;; GPS converter

(Defun C:gpsfilter ()
(setq kolkinlaat(ssget "_X" '((0 . "TEXT,MTEXT")(1 . "Kolken,Inlaat"))))
(command "-layer" "make" "N-Layer-Kolkinlaat" "")
(command ".laycur" kolkinlaat "")
)

 

It selects all the texts but also returns a 'nil' output in command bar.

 

It works (in a crude way, i want to add some IF and AND's and what not), but i wonder that the 'nil' returns come from and why it does that.

 

i believe the comma between 'Kolken' and 'Inlaat' causes some trouble?

 

Perhaps i need to do a 'find and replace' action first?

Link to comment
Share on other sites

(command ...) always returns nil. And since this is the last statement of your defun the function also returns nil.

Link to comment
Share on other sites

Ah, i guess i missed the '(princ)' part at the end of the command.

 

Built it bigger with multiple text contents to find and it seems to work perfectly, so i guess no worries there.

 

For future reference (or perhaps some people want to improve this basic code)

my code so far:

 

;;; GPS converter

(Defun C:gpsfilter ()
(setq kolkinlaat(ssget "_X" '((0 . "TEXT,MTEXT")(1 . "Kolken,Inlaat"))))
(setq kolktstuk(ssget "_X" '((0 . "TEXT,MTEXT")(1 . "Kolken,T-stuk"))))
(setq huisdwainlaat(ssget "_X" '((0 . "TEXT,MTEXT")(1 . "Huisaansluiting - DWA,Inlaat"))))
(setq overig(ssget "_X" '((0 . "TEXT,MTEXT")(1 . "Overig*"))))
(setq huisdwabocht(ssget "_X" '((0 . "TEXT,MTEXT")(1 . "Huisaansluiting - DWA,Bocht"))))
;; Top part searches for text content and places textobjectsin a SETQ
;; Bottom part creates layers, when creating layer it goes to current and
;; then i place 'SETQ' content to the current layer.
(command "-layer" "make" "R-XX-KOLK_INLAAT-T" "")
(command ".laycur" kolkinlaat "")
(command "-layer" "make" "R-XX-KOLKLEIDING_T_STUK-T" "")
(command ".laycur" kolktstuk "")
(command "-layer" "make" "R-XX-HUISAANSLUITING_DWA_INLAAT-T" "")
(command ".laycur" huisdwainlaat "")
(command "-layer" "make" "R-XX-RIOOL_OVERIGE-T" "")
(command ".laycur" overig "")
(command "-layer" "make" "R-XX-HUISAANSLUITING_DWA_BOCHT-T" "")
(command ".laycur" huisdwabocht "")
(princ)
)

 

(and for the people who don't understand the words, its dutch :))

Link to comment
Share on other sites

As an alternative method if the comma may be doing some funny things in the ssget filter why not just check the text within 1 big selection set using a series of cond statements and put on correct layer.

Link to comment
Share on other sites

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