Search code examples
autocadautolisp

How to merge two commands in one, to select entities and add property sets in a quantity schedule table?


I'm trying to combine to autocad commands to one. The commands is used for selecting entities for a schedule table and adding the property sets.

The first command is: ScheduleSelectionAdd The second command is: AecAddAllPropSets

My code so far:

(defun c:upDateSchedule()
    (command "ScheduleSelectionAdd")
    (command "AecAddAllPropSets")
(princ)
)

I have also tried this:

(defun c:upDateSchedule()
    (command "ScheduleSelectionAdd" "" "AecAddAllPropSets" "")
(princ)
)

Every time it only adds my selected entities to the table and not updating my property sets, so here I'm stuck.

TIA


Solution

  • Acquire the selection first, using ssget, and then pass the selection to each command, for example:

    (defun c:updateschedule ( / sel )
        (if (setq sel (ssget "_:L"))
            (command 
                "_.scheduleselectionadd" sel "" 
                "_.aecaddallpropsets"    sel ""
            )
        )
        (princ)
    )
    

    Here, the :L mode string excludes objects on locked layers.

    Note that the above assumes that these commands only have a single prompt for a selection of objects.