From: Martti Halminen
Subject: Re: AutoLisp Question : AutoCAD r14
Date: 
Message-ID: <3C6849CB.338691A@kolumbus.fi>
Michael Bulatovich wrote:

> I'm reposting something that went unanswered in my usual CAD related groups
> in this group with trepidation. The best I ever hope to achieve with
> AutoLisp is to get something (anything) to just work, and the standards here
> would seem to be a bit higher than that. Never-the-less, here goes:

The reason we usually refer AutoLisp (or VisualLisp) questions to
comp.cad.acad is that most people here do their programming in Common
Lisp. (For example it is 3 years since I did anything serious with
AutoCad, and don't currently have access to one.)

> The entity data list for these blocks
> lacks a pair, so I've been trying to use vl-remove to strip off a pair for
> color or linetype foe each piece of shrapnel that was ByBlock for either
> property. Can I use it like this:

> (vl-remove (assoc 6 e0data) e0data) ? Will this strip the pair (6 . foo)
> from the entity data?

What is preventing you from typing this on ACAD command line and trying
what happens?


Without the manual it is a little difficult to say, but if it behaves
like CL's remove, you might observe something like this:



USER(1): (setq e0data (list (cons 5 'jjj)(cons 32 'kkkk)
                            (cons 6 5)(cons 2 'lll)))
          ((5 . JJJ) (32 . KKKK) (6 . 5) (2 . LLL))
USER(2): (remove (assoc 6 e0data) e0data)
          ((5 . JJJ) (32 . KKKK) (2 . LLL))
USER(3): e0data
          ((5 . JJJ) (32 . KKKK) (6 . 5) (2 . LLL))


So, what happens is that REMOVE removes the offending value from the
list it returns. It will not be removed from the original list; what is
returned is a modified copy of the original.

So, the way to use this would be

(setq e0data (remove (assoc 6 e0data) e0data))


--

From: Michael Bulatovich
Subject: Re: AutoLisp Question : AutoCAD r14
Date: 
Message-ID: <46Y98.11622$X2.133991@nnrp1.uunet.ca>
"Martti Halminen" <···············@kolumbus.fi> wrote in message
·····················@kolumbus.fi...
> Michael Bulatovich wrote:
>
> > I'm reposting something that went unanswered in my usual CAD related
groups
> > in this group with trepidation. The best I ever hope to achieve with
> > AutoLisp is to get something (anything) to just work, and the standards
here
> > would seem to be a bit higher than that. Never-the-less, here goes:
>
> The reason we usually refer AutoLisp (or VisualLisp) questions to
> comp.cad.acad is that most people here do their programming in Common
> Lisp. (For example it is 3 years since I did anything serious with
> AutoCad, and don't currently have access to one.)
>
> > The entity data list for these blocks
> > lacks a pair, so I've been trying to use vl-remove to strip off a pair
for
> > color or linetype foe each piece of shrapnel that was ByBlock for either
> > property. Can I use it like this:
>
> > (vl-remove (assoc 6 e0data) e0data) ? Will this strip the pair (6 . foo)
> > from the entity data?
>
> What is preventing you from typing this on ACAD command line and trying
> what happens?
>
>
> Without the manual it is a little difficult to say, but if it behaves
> like CL's remove, you might observe something like this:
>
>
>
> USER(1): (setq e0data (list (cons 5 'jjj)(cons 32 'kkkk)
>                             (cons 6 5)(cons 2 'lll)))
>           ((5 . JJJ) (32 . KKKK) (6 . 5) (2 . LLL))
> USER(2): (remove (assoc 6 e0data) e0data)
>           ((5 . JJJ) (32 . KKKK) (2 . LLL))
> USER(3): e0data
>           ((5 . JJJ) (32 . KKKK) (6 . 5) (2 . LLL))
>
>
> So, what happens is that REMOVE removes the offending value from the
> list it returns. It will not be removed from the original list; what is
> returned is a modified copy of the original.
>
> So, the way to use this would be
>
> (setq e0data (remove (assoc 6 e0data) e0data))

Exactly what I tried, but it isn't behaving that way, and I have now
resorted to clumsier hacks to get the same result. The vl-* commands are
kind of exotic in AutoLISP- not many are experienced with them, hence my
trying this group. Thanks anyway.
--

MichaelB
www.michaelbulatovich.com
From: Reini Urban
Subject: Re: AutoLisp Question : AutoCAD r14
Date: 
Message-ID: <3C691295.401AC55B@x-ray.at>
Michael Bulatovich schrieb:
> "Martti Halminen" <···············@kolumbus.fi> wrote in message
> ·····················@kolumbus.fi...
> > So, the way to use this would be
> > (setq e0data (remove (assoc 6 e0data) e0data))
> 
> Exactly what I tried, but it isn't behaving that way, and I have now
> resorted to clumsier hacks to get the same result. The vl-* commands are
> kind of exotic in AutoLISP- not many are experienced with them, hence my
> trying this group. Thanks anyway.

right. I don't follow cca anymore, only this group ;(

vl-remove uses equal for comparison, and is of course not destructive 
(there's no vl-delete exported), 
so you have to use (setq e0data (vl-remove (assoc 6 e0data) e0data)).
if this will not work, there something wrong with your code.

which comparison it actually uses, we can only guess. it depends how adesk
represents 
its dotted pairs with integer keys internally. this might change. so far we
can safely 
assume that it uses equal, it always behaved like this.

if you don't like the vl- variant try the stdlib or FAQ counterpart instead:
  http://xarch.tu-graz.ac.at/autocad/stdlib/STDLIST.LSP
  http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html#20_1
this version is foolproof.
-- 
Reini Urban
  http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html
From: Michael Bulatovich
Subject: Re: AutoLisp Question : AutoCAD r14
Date: 
Message-ID: <mN8a8.11847$X2.137757@nnrp1.uunet.ca>
"Reini Urban" <······@x-ray.at> wrote in message
······················@x-ray.at...
> Michael Bulatovich schrieb:
> > "Martti Halminen" <···············@kolumbus.fi> wrote in message
> > ·····················@kolumbus.fi...
> > > So, the way to use this would be
> > > (setq e0data (remove (assoc 6 e0data) e0data))
> >
> > Exactly what I tried, but it isn't behaving that way, and I have now
> > resorted to clumsier hacks to get the same result. The vl-* commands are
> > kind of exotic in AutoLISP- not many are experienced with them, hence my
> > trying this group. Thanks anyway.
>
> right. I don't follow cca anymore, only this group ;(

And you are missed, Reini.

> vl-remove uses equal for comparison, and is of course not destructive
> (there's no vl-delete exported),
> so you have to use (setq e0data (vl-remove (assoc 6 e0data) e0data)).
> if this will not work, there something wrong with your code.


There's something else wrong with my code  ;(

> if you don't like the vl- variant try the stdlib or FAQ counterpart
instead:
>   http://xarch.tu-graz.ac.at/autocad/stdlib/STDLIST.LSP
>   http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html#20_1
> this version is foolproof.


What an elegant solution! My kludge appears to be working while I inspect
the variable:

(setq rear (cdr (member (assoc 62 entdata) entdata)))
   (setq datarev (reverse entdata))
   (setq tnorf (cdr (member (assoc 62 datarev) datarev)))
   (setq front (reverse tnorf))
   (setq entdata (append front rear))
   (entmod entdata)

...but if the original block was ByLayer/ByLayer the ByBlock elements remain
unchanged. Something is wrong elsewhere, I'm sure.
From: Eduardo Muñoz
Subject: Re: AutoLisp Question : AutoCAD r14
Date: 
Message-ID: <uk7tir1b6.fsf@jet.es>
"Michael Bulatovich" <···················@ica.net> writes:


> ...but if the original block was ByLayer/ByLayer the ByBlock elements remain
> unchanged. Something is wrong elsewhere, I'm sure.

I don't know what are you trying to do so this is
a long shot (and of topic too :)

When you entget an entity that has color ByLayer
it will not return a 62 dxf code, so you can't
mess with it. So if you want to entmod an entity
to be ByLayer you will have to append '(62 . 256)
to the list.


-- 

Eduardo Mu�oz
From: Michael Bulatovich
Subject: Re: AutoLisp Question : AutoCAD r14
Date: 
Message-ID: <tVka8.12608$X2.142703@nnrp1.uunet.ca>
"Eduardo Mu�oz" <···@jet.es> wrote in message ··················@jet.es...
> "Michael Bulatovich" <···················@ica.net> writes:
>
>
> > ...but if the original block was ByLayer/ByLayer the ByBlock elements
remain
> > unchanged. Something is wrong elsewhere, I'm sure.
>
> I don't know what are you trying to do so this is
> a long shot (and of topic too :)
>
> When you entget an entity that has color ByLayer
> it will not return a 62 dxf code, so you can't
> mess with it.

That's my problem. The same goes linetype (group 6).

So if you want to entmod an entity
> to be ByLayer you will have to append '(62 . 256)
> to the list.

256=ByLayer?! Thank You! Is there a similar fix for the ByLayer Linetype?
ByBlock linetypes have a (6 . "ByBlock") group and ByLayer linetypes have no
6 dxf code, so I've been trying ways of stripping the pair out of the
association list without any luck ;(
From: Eduardo Muñoz
Subject: Re: AutoLisp Question : AutoCAD r14
Date: 
Message-ID: <uadud451n.fsf@jet.es>
"Michael Bulatovich" <···················@ica.net> writes:

> 256=ByLayer?! Thank You! Is there a similar fix
> for the ByLayer Linetype?

(6  . "BYLAYER")

-- 

Eduardo Mu�oz
From: Michael Bulatovich
Subject: Re: AutoLisp Question : AutoCAD r14
Date: 
Message-ID: <BnAa8.12867$X2.147225@nnrp1.uunet.ca>
"Eduardo Mu�oz" <···@jet.es> wrote in message ··················@jet.es...
> "Michael Bulatovich" <···················@ica.net> writes:
>
> > 256=ByLayer?! Thank You! Is there a similar fix
> > for the ByLayer Linetype?
>
> (6  . "BYLAYER")

That one is too easy. I thought I tried that early on and got a bad dxf
message, but thanks a lot. My routine rocks! Maybe I'll get around to adding
a section to explode attributes to text   ; }