Help with addselected in autolisp

Help with addselected in autolisp

DC-MWA
Collaborator Collaborator
1,236 Views
8 Replies
Message 1 of 9

Help with addselected in autolisp

DC-MWA
Collaborator
Collaborator

Working on a "draft by pick" routine.

It almost works.

I can't get it to use the current aec style for soors, walls, windows like the native walladdselected, windowaddselected, dooraddselected commands do.

Also, it will not match dimensions scale as the native addselected command does.

 

I think I'm using entsel and ssget wrong.

 

It would also be nice if after running the routine of all style, layer, linetype settings returned back to before using.

 

I have attached the lisp file.

0 Likes
Accepted solutions (1)
1,237 Views
8 Replies
Replies (8)
Message 2 of 9

devitg
Advisor
Advisor

Learn about SSADD . 

0 Likes
Message 3 of 9

DC-MWA
Collaborator
Collaborator

Adding to selection? I only want one selection and to issue command by name of item picked.

0 Likes
Message 4 of 9

devitg
Advisor
Advisor
(setq entspecial (ssget "L"))


( (or (= CMD "POLYLINE") (= CMD "LWPOLYLINE")) (command "addselected" entspecial) )

I have no civil 

 

you can try 

 

Adds an object (entity) to a selection set, or creates a new selection set

Supported Platforms: Windows and Mac OS

Signature
(ssadd [ename [ss]])
ename
Type: Ename (entity name)

An entity name.

ss
Type: Pickset (selection set)

A selection set.

Return Values
Type: Pickset (selection set) or nil

The modified selection set passed as the second argument, if successful; otherwise nil.
0 Likes
Message 5 of 9

DC-MWA
Collaborator
Collaborator

You lost me.

My programming is limited as you can see.

0 Likes
Message 6 of 9

DC-MWA
Collaborator
Collaborator

It issues the command, but it does not act like the native addselected, walladdselected, dooraddseletec, windowaddselected cmmands.

It issues command but used the current wall, door, window, dimension settings rather than using the data from the slected item as the native commands do.

If I do the same thing on the command line it works great.

So the it seems that the selection is feeding the addselected functions wrong.

0 Likes
Message 7 of 9

Kent1Cooper
Consultant
Consultant

The (command) function works only with native AutoCAD command names.  Plain old ADDSELECTED is one of those, but not  the ones with prefixes such as WALL.  Custom-defined commands such as those are called using the name with the C: prefix under which it was (defun)'d, and in parentheses:

(C:WALLADDSELECTED)

but you're not supposed to be able to use arguments, such as your entity, in such a calling of a custom command.

 

I don't have the Architectural package, so I can't try it, but if you Search this Forum, there are threads about getting custom-defined commands to work, even including maybe some arguments.  Shot in the dark -- you could try making the object a pre-selection and call the C:Command, e.g.:

    (
       (= CMD "AEC_WALL")

       (sssetfirst nil (ssadd entspecial)); pre-select/highlight/grip it
       (C:WALLADDSELECTED); call the command
    )

Kent Cooper, AIA
0 Likes
Message 8 of 9

dbhunia
Advisor
Advisor
Accepted solution

Hi

 

I gone through your code......

 

What I get there if you replace the line.....

 

(setq entspecial (ssget "L"));;;;;;;it gives a selection set

with (setq entspecial (cdr (assoc -1 ENT)));;;;;;it gives a entity name

 

Because "ADDSELECTED" wants Either "Select object" (by direct user input) Or "Entity Name" (In code).

 

your code may work, because I do not know which AutoCAD you are using..........

 

I tested in AutoCAD 2017, here only "ADDSELECTED" is available ........

 

And if the other commands are not native AutoCAD command, then approach with the process as @Kent1Cooper said......

 

Check the sample code for "TEXT" only........

 

 

(defun C:1 (/ entspecial)
(setvar "cmdecho" 0)
(setq ENT (entget (car(entsel "\nSelect object: "))))
(setq CMD (cdr (assoc 0 ENT)))
(setq entspecial (cdr (assoc -1 ENT)));Get Entity name
(cond
(
(= CMD "TEXT")
(Command "ADDSELECTED" entspecial
(getpoint "\nSelect Insertion Point: ")
""
""
(getstring "\nType desired text: ")
)
)
)
(setvar "cmdecho" 1)
)


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 9 of 9

DC-MWA
Collaborator
Collaborator

Thank you.

0 Likes