ssname single object selection

ssname single object selection

robert06
Collaborator Collaborator
1,832 Views
12 Replies
Message 1 of 13

ssname single object selection

robert06
Collaborator
Collaborator

I'm trying to add rotation actions to parameters in block editor and get:

 

*Invalid selection*
Expects a single object.
; error: Function cancelled

 

It seems that ss1 is not accepted as a single object:

 

(defun c:bt-test (/ y i set1 ss1 ss apt)
(setq set1 (ssget "X" '((-4 . "<NOT")(-4 . "<AND")(0 . "*ACTIONENTITY")(-4 . "AND>")(-4 . "NOT>"))))
(if (and (setq ss (ssget "x" '((0 . "ROTATIONPARAMETERENTITY"))))
(setq i -1)
(setq y -1)
)
(repeat (sslength ss)
(setq ss1 (ssname ss (setq i (1+ i))))
(setq y (+ y -0.5))
(setq apt (list 4 y 0))
(command "bactiontool" "r" ss1 set1 "" apt)
)
)
(princ)
)

0 Likes
1,833 Views
12 Replies
Replies (12)
Message 2 of 13

Moshe-A
Mentor
Mentor



(command "bactiontool" "r" ss1 set1 "" apt)

it looks like your selection set (or one of then) does not contains the objects you expected

before reaching (command) function check the content of ss1 & set1 

 

moshe

0 Likes
Message 3 of 13

dlanorh
Advisor
Advisor

Post deleted. I've just twigged that your inside the block editor

I am not one of the robots you're looking for

0 Likes
Message 4 of 13

dlanorh
Advisor
Advisor
maybe because set1 is a selection set, and it is expecting entity names.

I am not one of the robots you're looking for

0 Likes
Message 5 of 13

robert06
Collaborator
Collaborator

Thank you for the replies.

It seems that ROTATIONPARAMETERENTITY as a dxf code in ss1 is the problem.

*ACTIONENTITY is a valid entry, as the following codes for example work fine.

I can't find dynamic block features documented for dxf group codes, the codes are detected by Acad "List" command.

The goal is to create Parameters, Actionentities and the selection sets for Actions by a single lisp.

 

(defun c:bawa (/ set1) ;; Bactionset new ALL but actions (BactionsetAllWithoutActions)
(setq set1 (ssget "X" '((-4 . "<NOT")(-4 . "<AND")(0 . "*ACTIONENTITY")(-4 . "AND>")(-4 . "NOT>"))))
(command "bactionset" pause "n" set1 "")
(princ)
)

 

(defun c:braw (/ set1 ss i ss1) ;; new Bactionset to every ROTATEACTIONENTITY of All objects but Actions
(setq set1 (ssget "X" '((-4 . "<NOT")(-4 . "<AND")(0 . "*ACTIONENTITY")(-4 . "AND>")(-4 . "NOT>"))))
(if (and (setq ss (ssget "x" '((0 . "ROTATEACTIONENTITY"))))
(setq i -1) ;;counter
)
(repeat (sslength ss)
(setq ss1 (ssname ss (setq i (1+ i))))
(command "bactionset" ss1 "n" set1 "")
)
)
(princ)
)

 

(defun c:baaw (/ set1 ss i ss1) ;; new Bactionset to every ACTIONENTITY of All objects but Actions
(command ".undo" "begin")
(setq set1 (ssget "X" '((-4 . "<NOT")(-4 . "<AND")(0 . "*ACTIONENTITY")(-4 . "AND>")(-4 . "NOT>"))))
(if (and (setq ss (ssget "x" '((0 . "*ACTIONENTITY"))))
(setq i -1) ;;counter
)
(repeat (sslength ss)
(setq ss1 (ssname ss (setq i (1+ i))))
(command "bactionset" ss1 "n" set1 "")
)
)
(command "undo" "end")
(princ)

)

 

0 Likes
Message 6 of 13

robert06
Collaborator
Collaborator

Sorry, my last post was confuzing!

The selection sets are OK, as they both give correct sslenght.

 

0 Likes
Message 7 of 13

dlanorh
Advisor
Advisor
I have tried your lisp on a block in the block editor and hit the same problem as you. The entity name for the rotation parameter is correct, but bactiontool refuses to accept a rotation parameter being passed as an entity name and requires a physical on screen selection. This suggests it is not possible to to pass parameters due either to limitations in the bactiontool command, or limitations on lisp working within the block editor, or both.
If i try to entget the data of the parameter I get only the entity name (-1 code), converting it to an object also fails, and if i try to inspect it in the vlide, vlide errors.

I am not one of the robots you're looking for

Message 8 of 13

robert06
Collaborator
Collaborator

Thank you for the conclusion on this.

 

What I'm failing to script here is generating a Parameter Set, which can be done in Block Authoring pallete.

On commandline we need to use separate commands for this (Bparameter + Bactiontool). I wonder how "Parameter Set" could be issued on command line / lisp to use in the repetition?

 

0 Likes
Message 9 of 13

dlanorh
Advisor
Advisor
I could well be wrong, but this may not be possible using lisp. Dynamic blocks didn't appear in autocad until 2006, by which time autodesk were starting to move away from lisp to .NET. It may be possible to do what you want in .NET, but i'm afraid i couldn't help you with that, as i know very little about it.

I am not one of the robots you're looking for

0 Likes
Message 10 of 13

roland.r71
Collaborator
Collaborator

@dlanorh wrote:
I have tried your lisp on a block in the block editor and hit the same problem as you. The entity name for the rotation parameter is correct, but bactiontool refuses to accept a rotation parameter being passed as an entity name and requires a physical on screen selection. This suggests it is not possible to to pass parameters due either to limitations in the bactiontool command, or limitations on lisp working within the block editor, or both.
If i try to entget the data of the parameter I get only the entity name (-1 code), converting it to an object also fails, and if i try to inspect it in the vlide, vlide errors.

Yep. I get the exact same wierd result.

!ss1

(<Entity name: 7ff66de5d380>)

(entget ss1)

((-1 . <Entity name: 7ff66de5d380>))

 

To top it off, i got an "unhandeled exception" on CTRL+C on that last line ... Smiley Frustrated

 

This is definately not my expertise, but I tried a few things, non of it worked. Strangly it doesn't report any error (on ss1) with the original code, but it doesn't work... (as you can see, it repeats the Select parameter: line as much as you have preset "answers" (4) before it asks for a selection set (Specify selection set for action) where it repeats the command: bactiontool and only then it sayz: *Invalid selection*

 

Simply calling (command "bactiontool" "r" ss1) will immediately give the error.

(command "bactiontool" "r" set1) does not.

 

It's looks as if the set1 IS accepted where ss1 is not. Meaning: ss1 is expected to be a selection set, too.

At least, that's what it looks like to me. (but dynamic blocks & editing them by lisp is something i never do/did)

0 Likes
Message 11 of 13

robert06
Collaborator
Collaborator

Using 'bactiontool' command without a lisp selection methods other than picking a parameter with cursor are available neither (last, previous), you'll get the same error message:

*Invalid selection*
Expects a single object.

 

In autocad a similar issue is present with basic 'offset' command.

0 Likes
Message 12 of 13

roland.r71
Collaborator
Collaborator

@robert06 wrote:

Using 'bactiontool' command without a lisp selection methods other than picking a parameter with cursor are available neither (last, previous), you'll get the same error message:

*Invalid selection*
Expects a single object.

 

In autocad a similar issue is present with basic 'offset' command.


Strangly it never tells me it "Expects a single object." (for the SS1 position) and while testing it accepts the selection set, not the single object... (which is totally incomplete anyway, as you can see with the entget posted earlier.) -not that i got it to work though.

 

When using the original code i get:

Command: (setq set1 (ssget "X" '((-4 . "<NOT")(-4 . "<AND")(0 . "*ACTIONENTITY")(-4 . "AND>")(-4 . "NOT>"))))
<Selection set: 40>

Command: (if (and (setq ss (ssget "x" '((0 . "ROTATIONPARAMETERENTITY"))))
((_> (setq i -1)
((_> (setq y -1)
((_> )
(_> (repeat (sslength ss)
((_> (setq ss1 (ssname ss (setq i (1+ i))))
((_> (setq y (+ y -0.5))
((_> (setq apt (list 4 y 0))
((_> (command "bactiontool" "r" ss1 set1 "" apt)
((_> )
(_> )
bactiontool
Enter action type [Array/Lookup/Flip/Move/Rotate/Scale/sTretch/Polar stretch]: r
Select parameter:
Select parameter:
Select parameter:
Select parameter:
Specify selection set for action
Select objects: bactiontool

*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/ALL/Fence/WPolygon/CPolygon/Group/Add/Remove/Multiple/Previous/Undo/AUto/SIngle
; error: Function cancelled

Select objects: *Cancel*

 

As you can see, it asks for a parameter 4 times (should be just 1) THEN it asks for a selection set.

At the prompt "Select objects" (=multiple!) it answers: BACTIONTOOL - which is a repeating of the initial command.

THEN it tells you BACTIONTOOL is a *Invalid selection* expecting a point or blah,blah,blah.

 

BTW: i'm testing the code while editing a dynamic block including rotations.

 

edit:

What happens is that the function ignores most if not all entries.

Select parameter: ss1 (ignored ?)

Select parameter: set1 (ignored ?)

Select parameter: "Empty space" (ignored ?)

Select parameter: apt (accepted ?)

Specify selection set for action

Select objects: <as there's no more preset answers within your "command" statement, it repeats the last command: BACTIONTOOL = invalid selection>

 

0 Likes
Message 13 of 13

robert06
Collaborator
Collaborator

I see, the command sequence gets messed up when ss1 is rejected, can't figure it out.

0 Likes