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

Table search?

14 REPLIES 14
Reply
Message 1 of 15
Anonymous
156 Views, 14 Replies

Table search?

Can someone please explain to me how table search is used to the best
effect? For example, I want to check for a specific layer made up of three
letters, but the first letter can be different, such as SDI, CDI, ADI, EDI,
PDI, FDI. If that layer isn't there, I'd like to create the layer according
to the discipline menu that's loaded. (Hence the S, C, A etc.) Then I want
to build a routine from there.

I'm learning how to do this so I'd rather have guidance and a little
patience, than to have someone totally do it for me. I would appreciate any
and all help. Any body care to get me started?

TIA,
Debi
14 REPLIES 14
Message 2 of 15
Anonymous
in reply to: Anonymous

Debi,

Are you ready to use activex methods?
or just want to use entmake or command?

(if (tblsearch "layer" layername)


)

-Luis
www.arqcom.com.mx


"Debi Olson" wrote in message
news:9A55ED78484CF750C3BE350F88DE3F12@in.WebX.maYIadrTaRb...
> Can someone please explain to me how table search is used to the best
> effect? For example, I want to check for a specific layer made up of three
> letters, but the first letter can be different, such as SDI, CDI, ADI,
EDI,
> PDI, FDI. If that layer isn't there, I'd like to create the layer
according
> to the discipline menu that's loaded. (Hence the S, C, A etc.) Then I want
> to build a routine from there.
>
> I'm learning how to do this so I'd rather have guidance and a little
> patience, than to have someone totally do it for me. I would appreciate
any
> and all help. Any body care to get me started?
>
> TIA,
> Debi
>
>
Message 3 of 15
Anonymous
in reply to: Anonymous

Luis, you've helped me before and know what a "greenhorn" I am ;-). You are
going to have to explain the difference and which one I'll have an easier
time using at this point.


"Luis Esquivel" wrote in message
news:6A3C55FC1D30AA04887D6899E1FA0674@in.WebX.maYIadrTaRb...
Debi,

Are you ready to use activex methods?
or just want to use entmake or command?

(if (tblsearch "layer" layername)


)

-Luis
www.arqcom.com.mx


"Debi Olson" wrote in message
news:9A55ED78484CF750C3BE350F88DE3F12@in.WebX.maYIadrTaRb...
> Can someone please explain to me how table search is used to the best
> effect? For example, I want to check for a specific layer made up of three
> letters, but the first letter can be different, such as SDI, CDI, ADI,
EDI,
> PDI, FDI. If that layer isn't there, I'd like to create the layer
according
> to the discipline menu that's loaded. (Hence the S, C, A etc.) Then I want
> to build a routine from there.
>
> I'm learning how to do this so I'd rather have guidance and a little
> patience, than to have someone totally do it for me. I would appreciate
any
> and all help. Any body care to get me started?
>
> TIA,
> Debi
>
>
Message 4 of 15
Anonymous
in reply to: Anonymous

I'm about to leave right now, I answer to you tomorrow.
Message 5 of 15
Anonymous
in reply to: Anonymous

Not sure what you mean by "according to the discipline menu that's loaded,"
but here's a quick-and-dirty method that will create each of the layers you
mention if they don't already exist.

(defun C:MakeDebisLayers ( )
(foreach x '("SDI" "CDI" "ADI" "EDI" "PDI" "FDI")
(if (not (tblsearch "layer" x))
(command "._-layer" "_n" x "")
)
)
)

In fact you could even skip the (if (not (tblsearch ...))) business and
simply use the following:

(defun C:MakeDebisLayers ( )
(foreach x '("SDI" "CDI" "ADI" "EDI" "PDI" "FDI")
(command "._-layer" "_m" x "")
)
)
___

"Debi Olson" wrote in message
news:9A55ED78484CF750C3BE350F88DE3F12@in.WebX.maYIadrTaRb...
> Can someone please explain to me how table search is used to the best
> effect? For example, I want to check for a specific layer made up of three
> letters, but the first letter can be different, such as SDI, CDI, ADI,
EDI,
> PDI, FDI. If that layer isn't there, I'd like to create the layer
according
> to the discipline menu that's loaded. (Hence the S, C, A etc.) Then I want
> to build a routine from there.
>
> I'm learning how to do this so I'd rather have guidance and a little
> patience, than to have someone totally do it for me. I would appreciate
any
> and all help. Any body care to get me started?
>
> TIA,
> Debi
>
>
Message 6 of 15
Anonymous
in reply to: Anonymous

Debi:

Starting with plain AutoLisp, you probably want to iterate using the
(tblnext) function spiced up with a little (wcmatch).

Just a simple example to see if any matching layers already exist:
(defun layermatch (spec / table layer rewind matches)
;; First note that spec had better be a string!
(if (/= (type spec) 'STR)(setq spec "*"))
(setq rewind 1) ; tblnext needs to know whether to start fresh
;; Note that I used 1 instead of T. That comes from the days pre-R15
;; when T was not protected, but 1 is always non-nil.
(while (setq table (tblnext "layer" rewind)) ; layer entity data
(setq layer (cdr (assoc 2 table)) ; layer name
rewind nil ; tell tblnext not to start fresh on the next
search
)
(if (wcmatch (strcase layer)(strcase spec)) ; don't let cases cloud
the search
(setq matches (cons layer matches))
)
)
(reverse matches) ; return the list of layer names that match in the
order they were found
)

You could employ it as (layermatch "SDI*,CDI*,ADI*")

Once you get this, we can help you add the missing layers.

--
John Uhden, Cadlantic/formerly CADvantage
--> mailto:juhden@cadlantic.com
--> http://www.cadlantic.com
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
FAX 732-528-1332

"Debi Olson" wrote in message
news:9A55ED78484CF750C3BE350F88DE3F12@in.WebX.maYIadrTaRb...
> Can someone please explain to me how table search is used to the best
> effect? For example, I want to check for a specific layer made up of three
> letters, but the first letter can be different, such as SDI, CDI, ADI,
EDI,
> PDI, FDI. If that layer isn't there, I'd like to create the layer
according
> to the discipline menu that's loaded. (Hence the S, C, A etc.) Then I want
> to build a routine from there.
>
> I'm learning how to do this so I'd rather have guidance and a little
> patience, than to have someone totally do it for me. I would appreciate
any
> and all help. Any body care to get me started?
Message 7 of 15
PeterW
in reply to: Anonymous

Hi.

Regarding your code:

(while (setq table (tblnext "layer" rewind))
(setq layer (cdr (assoc 2 table))
rewind nil
)

)

You might find that it is far easier and
simpler to use the table variable to control
the rewind like this:

(setq table nil)

(while (setq table (tblnext "layer" (not table)))

; process each table item in 'table' variable
)

As long as 'table' variable is nil when
entering the loop it will make tblsearch
rewind the first time through the loop,
and not rewind the remaining times.

I don't remember where I first saw this
but it is quite ingenous.

Peter
Message 8 of 15
Anonymous
in reply to: Anonymous

Another method:
(setq table (tblnext "layer" 1))
(while table
(setq layer (cdr (assoc 2 table))
table (tblnext "layer")
)

)

--
John Uhden, Cadlantic/formerly CADvantage
--> mailto:juhden@cadlantic.com
--> http://www.cadlantic.com
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
FAX 732-528-1332

"PeterW" wrote in message
news:f08a10b.5@WebX.maYIadrTaRb...
> Hi.
> Regarding your code:
>
> (while (setq table (tblnext "layer" rewind))
> (setq layer (cdr (assoc 2 table))
> rewind nil
> )
>
> )
>
> You might find that it is far easier and
> simpler to use the table variable to control
> the rewind like this:
>
> (setq table nil)
>
> (while (setq table (tblnext "layer" (not table)))
>
> ; process each table item in 'table' variable
> )
>
> As long as 'table' variable is nil when
> entering the loop it will make tblsearch
> rewind the first time through the loop,
> and not rewind the remaining times.
>
> I don't remember where I first saw this
> but it is quite ingenous.
>
> Peter
>
>
Message 9 of 15
Anonymous
in reply to: Anonymous

Paul,
What I mean by "discipline menu that's loaded" it that we have a largely
customized menu system with separate pull down menus for Structural,
Architectural, Civil, Fire Protection, etc.. The first letter of the layer
name indicates which discipline the layer belongs to. i.e.: sdi = Structural
DImension layer. I don't want to create all the layers listed previously,
I'd like it to search for any of them and if it isn't present, to create
that layer according to the discipline menu currently loaded.
"Paul Turvill" wrote in message
news:1B64162675DE8C8D81AEA1595A92C7C6@in.WebX.maYIadrTaRb...
Not sure what you mean by "according to the discipline menu that's loaded,"
but here's a quick-and-dirty method that will create each of the layers you
mention if they don't already exist.

(defun C:MakeDebisLayers ( )
(foreach x '("SDI" "CDI" "ADI" "EDI" "PDI" "FDI")
(if (not (tblsearch "layer" x))
(command "._-layer" "_n" x "")
)
)
)

In fact you could even skip the (if (not (tblsearch ...))) business and
simply use the following:

(defun C:MakeDebisLayers ( )
(foreach x '("SDI" "CDI" "ADI" "EDI" "PDI" "FDI")
(command "._-layer" "_m" x "")
)
)
___

"Debi Olson" wrote in message
news:9A55ED78484CF750C3BE350F88DE3F12@in.WebX.maYIadrTaRb...
> Can someone please explain to me how table search is used to the best
> effect? For example, I want to check for a specific layer made up of three
> letters, but the first letter can be different, such as SDI, CDI, ADI,
EDI,
> PDI, FDI. If that layer isn't there, I'd like to create the layer
according
> to the discipline menu that's loaded. (Hence the S, C, A etc.) Then I want
> to build a routine from there.
>
> I'm learning how to do this so I'd rather have guidance and a little
> patience, than to have someone totally do it for me. I would appreciate
any
> and all help. Any body care to get me started?
>
> TIA,
> Debi
>
>
Message 10 of 15
Anonymous
in reply to: Anonymous

John,

Where do I find the definitions for some of the terms/commands you have
used? I don't want to have to ask everything. You did explain a mystery
to me, however. There is some older code that uses 1 in the tblsearch and I
couldn't understand the setting. Thanks.
"John Uhden" wrote in message
news:2C656D5DE16940CAF90C148646FC3FA7@in.WebX.maYIadrTaRb...
Debi:

Starting with plain AutoLisp, you probably want to iterate using the
(tblnext) function spiced up with a little (wcmatch).

Just a simple example to see if any matching layers already exist:
(defun layermatch (spec / table layer rewind matches)
;; First note that spec had better be a string!
(if (/= (type spec) 'STR)(setq spec "*"))
(setq rewind 1) ; tblnext needs to know whether to start fresh
;; Note that I used 1 instead of T. That comes from the days pre-R15
;; when T was not protected, but 1 is always non-nil.
(while (setq table (tblnext "layer" rewind)) ; layer entity data
(setq layer (cdr (assoc 2 table)) ; layer name
rewind nil ; tell tblnext not to start fresh on the next
search
)
(if (wcmatch (strcase layer)(strcase spec)) ; don't let cases cloud
the search
(setq matches (cons layer matches))
)
)
(reverse matches) ; return the list of layer names that match in the
order they were found
)

You could employ it as (layermatch "SDI*,CDI*,ADI*")

Once you get this, we can help you add the missing layers.

--
John Uhden, Cadlantic/formerly CADvantage
--> mailto:juhden@cadlantic.com
--> http://www.cadlantic.com
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
FAX 732-528-1332

"Debi Olson" wrote in message
news:9A55ED78484CF750C3BE350F88DE3F12@in.WebX.maYIadrTaRb...
> Can someone please explain to me how table search is used to the best
> effect? For example, I want to check for a specific layer made up of three
> letters, but the first letter can be different, such as SDI, CDI, ADI,
EDI,
> PDI, FDI. If that layer isn't there, I'd like to create the layer
according
> to the discipline menu that's loaded. (Hence the S, C, A etc.) Then I want
> to build a routine from there.
>
> I'm learning how to do this so I'd rather have guidance and a little
> patience, than to have someone totally do it for me. I would appreciate
any
> and all help. Any body care to get me started?
Message 11 of 15
Anonymous
in reply to: Anonymous

How are you "loading" your custom menus? Are they full menus, partial menus
overlaying a standard one, or what?
___

"Debi Olson" wrote in message
news:CFD326B0EDCF4FBBC753617457825F2A@in.WebX.maYIadrTaRb...
> What I mean by "discipline menu that's loaded" it that we have a largely
> customized menu system with separate pull down menus for Structural,
> Architectural, Civil, Fire Protection, etc.. The first letter of the layer
> name indicates which discipline the layer belongs to. i.e.: sdi =
Structural
> DImension layer.
Message 12 of 15
Anonymous
in reply to: Anonymous

...my thought being that if you're using some sort of code to load the menus
(either full or partial), you could simply extend that code to create the
companion layer(s).
___

"Paul Turvill" wrote in message
news:AE6DDED80595E4C53ABCF81BF9C38F1A@in.WebX.maYIadrTaRb...
> How are you "loading" your custom menus? Are they full menus, partial
menus
> overlaying a standard one, or what?
Message 13 of 15
Anonymous
in reply to: Anonymous

Paul,

I hate to say this but I'm not sure of the definitions of partial menus. We
have a full menu (I think). We have the ACAD default menu loaded, the
express menu loaded, and our menu loaded. Within our menu, we have choices
of the pull downs that we want. They are all in the main AH.mnu structure.
We are able to switch from one discipline to another by using the pull down
menu and it will automatically unload the original and change it to the new
one. The darn thing is over 70 pages long and I did post it probably a month
ago because, oh boy was I lost, trying to see what was really necessary
after 10 years of customization lumped in. (Long story.)

So, anyway, when we load the menu it's with the menuload command.

Does that help?

Thanks,
Deb


"Paul Turvill" wrote in message
news:AE6DDED80595E4C53ABCF81BF9C38F1A@in.WebX.maYIadrTaRb...
How are you "loading" your custom menus? Are they full menus, partial menus
overlaying a standard one, or what?
___

"Debi Olson" wrote in message
news:CFD326B0EDCF4FBBC753617457825F2A@in.WebX.maYIadrTaRb...
> What I mean by "discipline menu that's loaded" it that we have a largely
> customized menu system with separate pull down menus for Structural,
> Architectural, Civil, Fire Protection, etc.. The first letter of the layer
> name indicates which discipline the layer belongs to. i.e.: sdi =
Structural
> DImension layer.
Message 14 of 15
Anonymous
in reply to: Anonymous

Paul,

This is what I get (text screen) when I change the discipline. In this
particular one, I started of in structural, went to architectrual, and then
back to structural.

Command: (menucmd (STRCAT "GAH.LIB"LMENU"=AH.SWITDISC"))(menucmd
"GAH.SWITDISC=*") ""

Command: (SETQ LTEMP "STRUCT")(menucmd (STRCAT
"GAH.SWITDISC=AH.LIB"LTEMP))(SWITDISC)(PRINC)
Command: (menucmd (STRCAT "GAH.LIB"LMENU"=AH.SWITDISC"))(menucmd
"GAH.SWITDISC=*") ""

Command: (SETQ LTEMP "ARCH")(menucmd (STRCAT
"GAH.SWITDISC=AH.LIB"LTEMP))(SWITDISC)(PRINC)
Command: (menucmd (STRCAT "GAH.LIB"LMENU"=AH.SWITDISC"))(menucmd
"GAH.SWITDISC=*") ""

"Paul Turvill" wrote in message
news:AE6DDED80595E4C53ABCF81BF9C38F1A@in.WebX.maYIadrTaRb...
How are you "loading" your custom menus? Are they full menus, partial menus
overlaying a standard one, or what?
___

"Debi Olson" wrote in message
news:CFD326B0EDCF4FBBC753617457825F2A@in.WebX.maYIadrTaRb...
> What I mean by "discipline menu that's loaded" it that we have a largely
> customized menu system with separate pull down menus for Structural,
> Architectural, Civil, Fire Protection, etc.. The first letter of the layer
> name indicates which discipline the layer belongs to. i.e.: sdi =
Structural
> DImension layer.
Message 15 of 15
Anonymous
in reply to: Anonymous

Hi Debi

Try this:
(defun GetTableInfo (Nme / CurTbl TblLst)
(while (setq CurTbl (tblnext Nme (not CurTbl)))
(setq TblLst (cons CurTbl TblLst))
)
(reverse TblLst)
)

(defun NameFilter (Flt Tbl / ObjNme RetLst)
(foreach n (GetTableInfo Tbl)
(setq ObjNme (cdr (assoc 2 n)))
(if (wcmatch ObjNme Flt)
(setq RetLst (cons ObjNme RetLst))
)
(reverse RetLst)
)
)

Use (extract the specific Layer names):
(NameFilter "?DI" "LAYER")

Note:
Can be used also for other table access than Layers.

Cheers
--
Juerg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch


Debi Olson schrieb:
>
> Can someone please explain to me how table search is used to the best
> effect? For example, I want to check for a specific layer made up of three
> letters, but the first letter can be different, such as SDI, CDI, ADI, EDI,
> PDI, FDI. If that layer isn't there, I'd like to create the layer according
> to the discipline menu that's loaded. (Hence the S, C, A etc.) Then I want
> to build a routine from there.
>
> I'm learning how to do this so I'd rather have guidance and a little
> patience, than to have someone totally do it for me. I would appreciate any
> and all help. Any body care to get me started?
>
> TIA,
> Debi

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

Post to forums  

Autodesk Design & Make Report

”Boost