Is it possible..?

Is it possible..?

danglar
Advocate Advocate
1,216 Views
9 Replies
Message 1 of 10

Is it possible..?

danglar
Advocate
Advocate

Hi All.

Is ti possible to select selection set of converted by previous funclion items via lisp?

For example: The main function can convert selected by user circles to polylines ( see attached lisp)

and now we have NEW set of polylines..

How to select it?

Any help will be very appreciated

 

0 Likes
Accepted solutions (1)
1,217 Views
9 Replies
Replies (9)
Message 2 of 10

SeeMSixty7
Advisor
Advisor

There are a few different ways you can get there.

 

Prior to performing the conversion  use the (entlast) to get the last entity (Probably good to make sure this is NOT one of the object to get converted.) I would create an entity on purpose for this(Delete it when done). Then run through your conversion routine and then after each conversion compare the last ent to the new last ent. If it is different then add it to a selection set and at the end you have your selection set.

 

Another method is to take a selection set prior to running your conversion, then compare a new selection set, be sure to step over any entities in the Selection set that have been removed from the conversion process.

 

Hopefully one of those methods works for you.

 

Good luck,

 

 

0 Likes
Message 3 of 10

dbroad
Mentor
Mentor

Within the loop, wrap your entmake with an if.  For the then expression, add the last entity to your selection set.

(setq ss (ssadd)) ;;outside loop
....
(repeat
...
(if (entmake ....)
    (ssadd (entlast) ss)
    ;;else epxr if required to notify of problems
  )
....
);end repeat

SS will contain all of the new objects.

 

Architect, Registered NC, VA, SC, & GA.
Message 4 of 10

Kent1Cooper
Consultant
Consultant
Accepted solution

I would do it by putting in the creation of an empty selection set after the selection of Circles but before processing any of them:

 

(setq converted (ssadd))

 

and then within the (repeat) function that does the conversion, add a line after the conversion:

 

(ssadd (entlast) converted)

 

When it's done, you have a selection set of all of them in the 'converted' [or whatever you choose to call it] variable, to do with what you choose.

Kent Cooper, AIA
Message 5 of 10

danglar
Advocate
Advocate

As usual, EXELENT solution Kent!

As did all as you sad and now I have a selection set of converted entities.

You can see it in my attachment

Thank you Kent

0 Likes
Message 6 of 10

danglar
Advocate
Advocate

a little addition to highlight new selection set...

Thanks again Kent

0 Likes
Message 7 of 10

cadffm
Consultant
Consultant

You dont need entlast.

 

change your Entmake to EntmakeX

 

EntmakeX returns

If successful, entmakex returns the name of the entity created. If entmakex is unable to create the entity, the function returns nil.

 

(if (setq NewObj (entmakeX '(..)))

    (progn

       (ssadd NewObj converted)

       (entdel cir) ; <== A BETTER PLACE FOR THAT

    )

    (progn

       ; (ssadd (ssname csel 0) ErrorSS) ; <==  Just a suggestion of mine

       (alert (strcat "ERROR - Handle '" (cdr(assoc 5 (entget(ssname csel 0)))) "'"))

    )

)

 

HTH Sebastian

Sebastian

0 Likes
Message 8 of 10

Kent1Cooper
Consultant
Consultant

@danglar wrote:

a little addition to highlight new selection set...


I'm glad it works for you.  I do think you may have put in more than you really need -- it seems like some redundancy:

 

(command "select" converted "")
(sssetfirst nil converted)
           (ssget "_I")

 

It depends on what you plan to do with the selection.  The first one is all you need if you then want to call up some editing command to which you would give P[revious] as the selection [but you could also skip that Select command, if you give a command !converted as the selection].  The second one is all you need if you want them selected/highlighted and you want to then do something collectively with them all at once, such as give them a common Layer or color or width in the Properties box, or even [in place of using Select] call up an editing command with them as pre-selection.  I'm not sure the third one gives you anything that one or the other of the first two doesn't, so that one may be expendable in any case, but experiment with fewer of those.

Kent Cooper, AIA
0 Likes
Message 9 of 10

Kent1Cooper
Consultant
Consultant

@cadffm wrote:

You dont need entlast.

 

change your Entmake to Entmake....


That doesn't seem necessary to me.  I don't see any advantage to:

  (ssadd NewObj converted)

 

after making an otherwise unneeded variable, over

 

  (ssadd (entlast) converted)

 

That suggestion and @dbroad's are both working with (if) functions from the assumption that there might be failures in conversion.  But the selection will consist of nothing but Circle entities that are not on locked Layers, so I don't consider that a risk, or if there are failures, there's something deeper to be concerned about, and there will likely be more problems than not converting some Circle(s).  But if you want the extra "insurance," by all means add it, one way or the other.

 

However, if you do go that route, there's certainly no need to spell out  (ssname csel 0)  in two places -- just use the 'cir' variable -- that's what's in it.

Kent Cooper, AIA
0 Likes
Message 10 of 10

cadffm
Consultant
Consultant

You are perfectly right in this code case, now knows danglar and some other fellow readers
also the Lispfunktion entmakeX, which may be valuable in the future.

And the entdel-Statement should be in the (if)function.

 

cir <> (ssname csel 0) Absolutely right, the existing variable cir is to be used here.

 

 Excuse this unnecessary additional information.

 

 

Sebastian

0 Likes