PDA

View Full Version : Microstation Tentative Button Emulation Utilizing TENSEL.lsp Routine



gugg
2015-08-19, 05:08 PM
Originally posted 29NOV2011 ... Trying again to generate positive comments and help ...

A few years ago I was using Autocad release 9 and 10, I was using a lisp routine named "TENSEL.lsp" for the tentative button tool which mimicked "Microstation" tentative button.

If you are not an experienced Microstation user you may not understand the criteria in which the tentative button operates. I'm hoping an AutoLISP guru with Microstaion experience can look at the "TENSEL.lsp" code below and determine what is needed to get the LISP routine working in a more current environment (I'm using Autocad 2016). This was in the day of 3 and 4 button mouse. You can see the code lines for mouse button menu.

This LISP routine was written in 1989 by the infamous Tony Tanzillo. I haven't been able to make any contact with him for help.


TENSEL.lsp:


;|

TENSEL.LSP Copyright 1989, 1990 Tony Tanzillo All rights reserved.

Emulates Intergraph uSTN's "tentative" selection button by letting the user
selectively cycle thru, highlight and select one of several entities that
cross thru, or lie entirely within the pickbox.

When you to need select a single object in a crowded area where you cannot
isolate the desired object alone within the pickbox, then place the pickbox
over it as you normally would, and then press the "tentative" button. Then,
one of the objects that crosses the pickbox will be highlighted. To advance
the highlight to the next elegible object, press either the PICK button or
the SPACE bar. When the desired object is highlighted, press RETURN to
select it, and it will be passed directly to AutoCAD along with the initial
selection point.

You can also use the tentative button for selecting all objects that are
requested by AutoCAD commands, and it will detect an ambiguous selection
and let you select one of the objects in the pickbox. If there is only
one object in the pickbox, then it will be returned with the selection
point, just as if you had used the PICK button to select it.

Note that using the tentative button is only valid in response to object
selection in AutoCAD commands. It cannot be used in response to a prompt
to select an object that is requested by another AutoLISP program.

Remember that the current location of the cursor when you first press the
tentative button will be the selection point that gets passed to AutoCAD
along with the object you select.

This has been tested with AutoCAD Release 9 and 10.

Program listing:

(pixel) Returns size of display pixel at current magnification

(defun pixel () (/ (getvar "viewsize") (cadr (getvar "screensize"))))

(ssbox <point> ) Returns "crossing" selection of all objects within
a PICKBOX-sized crossing box centered on <point>.

(defun ssbox (pt / c1 c2 delta)
(setq pt (trans pt 1 2))
(setq delta (* (getvar "pickbox") (pixel)))
(ssget "c" (trans (mapcar '(lambda (x) (+ x delta)) pt) 2 1)
(trans (mapcar '(lambda (x) (- x delta)) pt) 2 1)))

(tensel) - Implements a "tentative" selection button for AutoCAD R10.

This function MUST be invoked via a button on the pointing device, as it
uses the current pickbox location as the initial and resulting selection
point. Edit your ACAD.MNU file, or whatever .MNU file you want to use
TENSEL with, and insert a call to (TENSEL) in your button menu.

Below is an example .MNU ***buttons section with the tentative button
assigned to button number three on the pointing device.

***BUTTONS

^P(tensel)
^C^C
^B

|;

(defun tensel ( / ss pt e i l k RETURN)

(setq RETURN '( (2 13)
(6 0) ; <-- This is button ZERO on the pointing
) ; device, it is normally assigned to
) ; RETURN. If you have RETURN assiged
; to another button, then change the
; ZERO in the list (6 0) to the number
; of the button assigned to RETURN.
(cond
( (not (setq ss (ssbox (setq pt (cadr (grread t)))))) pt)
( (eq 1 (setq l (sslength ss)))
(list (ssname ss 0) pt))
(t (setq e (ssname ss 0) i 0)

; Once you've gotten the hang of it, you can remove this
; prompt expression.
; ------------------------------------------------------

(princ (strcat "\nFound " (itoa l) " elegible objects."
"\nUse SPACE/PICK button to highlight next "
"elegible object, RETURN to select."))
; ------------------------------------------------------

(redraw e 3)
(while (not (member (setq k (grread)) RETURN))
(cond ( (or (eq (car k) 3) (equal k '(2 32)))
(redraw e)
(redraw
(setq e
(ssname ss
(setq i (cond ( (= i (1- l)) 0)
(t (1+ i)))))) 3))))
(redraw e)
(terpri)
(list e pt)))
)

Tom Beauford
2015-08-20, 12:31 PM
Unlike Microstation AutoCAD has multiple ways to handle that built in. Take a look at the legacyctrlpick (http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-7FD66320-FC7D-4855-886A-C4BF7B3F1C03) system variable.




LEGACYCTRLPICK (System Variable)
Specifies the Ctrl key behavior for selection cycling and subobject selection.

Type: Integer
Saved in: Registry
Initial value: 2



0 Ctrl+click is used to select subobjects (faces, edges, and vertices) on 3D solids, surfaces, and meshes.

1 Ctrl+click is used to cycle through overlapping objects. Disallows using Ctrl+click to select subobjects on 3D solids, surfaces, and meshes.

2 Ctrl+click is used to select subobjects (faces, edges, and vertices) on 3D solids, surfaces, and meshes when SUBOBJSELECTIONMODE is set to 0.If SUBOBJSELECTIONMODE is set to 1, 2, 3,4, or 5, it is not necessary to hold down the Ctrl key to select subobjects. If you hold down the Ctrl key when SUBOBJSELECTIONMODE is set to 1, 2, 3,4, or 5, the subobject filter is turned off until the Ctrl key is released.

AutoCAD has changed a lot with the last 21 releases over the last quarter century if you take the time to learn it you'll forget about how you used to have to do things in Microstation.

Tom Beauford
2015-08-20, 01:24 PM
Revised code below though it adds extra steps to functionality already included in AutoCAD.
;|

TENSEL.LSP Copyright 1989, 1990 Tony Tanzillo All rights reserved.

Emulates Intergraph uSTN's "tentative" selection button by letting the user
selectively cycle thru, highlight and select one of several entities that
cross thru, or lie entirely within the pickbox.

When you to need select a single object in a crowded area where you cannot
isolate the desired object alone within the pickbox, then place the pickbox
over it as you normally would, and then press the "tentative" button. Then,
one of the objects that crosses the pickbox will be highlighted. To advance
the highlight to the next elegible object, press either the PICK button or
the SPACE bar. When the desired object is highlighted, press RETURN to
select it, and it will be passed directly to AutoCAD along with the initial
selection point.

You can also use the tentative button for selecting all objects that are
requested by AutoCAD commands, and it will detect an ambiguous selection
and let you select one of the objects in the pickbox. If there is only
one object in the pickbox, then it will be returned with the selection
point, just as if you had used the PICK button to select it.

Note that using the tentative button is only valid in response to object
selection in AutoCAD commands. It cannot be used in response to a prompt
to select an object that is requested by another AutoLISP program.

Remember that the current location of the cursor when you first press the
tentative button will be the selection point that gets passed to AutoCAD
along with the object you select.

This has been tested with AutoCAD Release 9 and 10.

Program listing:

(pixel) Returns size of display pixel at current magnification |;


(defun pixel () (/ (getvar "viewsize") (cadr (getvar "screensize"))))

;| (ssbox <point> ) Returns "crossing" selection of all objects within
a PICKBOX-sized crossing box centered on <point>. |;

(defun ssbox (pt / c1 c2 delta)
(setq pt (trans pt 1 2))
(setq delta (* (getvar "pickbox") (pixel)))
(ssget "c" (trans (mapcar '(lambda (x) (+ x delta)) pt) 2 1)
(trans (mapcar '(lambda (x) (- x delta)) pt) 2 1)))

;| (tensel) - Implements a "tentative" selection button for AutoCAD R10.

This function MUST be invoked via a button on the pointing device, as it
uses the current pickbox location as the initial and resulting selection
point. Edit your ACAD.MNU file, or whatever .MNU file you want to use
TENSEL with, and insert a call to (TENSEL) in your button menu.

Below is an example .MNU ***buttons section with the tentative button
assigned to button number three on the pointing device.

***BUTTONS

^P(tensel)
^C^C
^B

|;

(defun tensel ( / ss pt e i l k RETURN)

(setq RETURN '( (2 13)
(6 0) ; <-- This is button ZERO on the pointing
) ; device, it is normally assigned to
) ; RETURN. If you have RETURN assiged
; to another button, then change the
; ZERO in the list (6 0) to the number
; of the button assigned to RETURN.
(cond
( (not (setq ss (ssbox (setq pt (cadr (grread t)))))) pt)
( (eq 1 (setq l (sslength ss)))
(list (ssname ss 0) pt))
(t (setq e (ssname ss 0) i 0)

; Once you've gotten the hang of it, you can remove this
; prompt expression.
; ------------------------------------------------------

(princ (strcat "\nFound " (itoa l) " elegible objects."
"\nUse SPACE/PICK button to highlight next "
"elegible object, RETURN to select."))
; ------------------------------------------------------

(redraw e 3)
(while (not (member (setq k (grread)) RETURN))
(cond ( (or (eq (car k) 3) (equal k '(2 32)))
(redraw e)
(redraw
(setq e
(ssname ss
(setq i (cond ( (= i (1- l)) 0)
(t (1+ i)))))) 3))))
(redraw e)
(setq ss (ssadd))(ssadd e ss)
(sssetfirst nil ss)
(terpri)
(list e pt)))
)
After loading the code with (load "TENSEL.lsp") enter (TENSEL) with the curser on the lines you wish to pick from.
It can be run by adding it in the CUI Shortcut Menu "Context menu for default mode" and "Context menu for command mode".

I recommend setting LEGACYCTRLPICK to 0. Then with a command active Shift+Spacebar while pickbox is over several lines will toggle highlight to each object below pickbox, then pick to select the highlighted one. Works about the same as you were used to and saves a step or two over using the lisp.

gugg
2015-08-20, 05:28 PM
I DON'T THINK IT'S PRODUCTIVE TO HEAR THAT CRITICISM FROM YOU ABOUT LEARNING AUTOCAD ... YOU DON'T KNOW ME AND SHOULDN'T JUDGE BECAUSE I ASKED FOR HELP. I UNDERSTAND SELECTIONMODE ETC.

Tom Beauford
2015-08-20, 05:47 PM
I DON'T THINK IT'S PRODUCTIVE TO HEAR THAT CRITICISM FROM YOU ABOUT LEARNING AUTOCAD ... YOU DON'T KNOW ME AND SHOULDN'T JUDGE BECAUSE I ASKED FOR HELP. I UNDERSTAND SELECTIONMODE ETC.

Didn't mean to offend, just trying to point out that's a big leap from versions 9 & 10 to 2016. AutoCAD is a completely different program now. Have you tried with LEGACYCTRLPICK set to 0? Don't know anything about Microstation's tentative button, but that seems to work the same as the lisp I tried to debug for you. Have you tried the modified code?

gugg
2015-08-20, 06:03 PM
THANKS FOR THE LEGACYCTRLPICK SUGGESTION. I'LL LOOK AT THE MODE OPTIONS AND SEE HOW IT HELPS.

THE MAIN PURPOSE OF THE TENTATIVE BUTTON OPTION IN MICROSTATION IS IF I WANT TO PLACE AN ENTITY A CERTAIN "X & Y" DISTANCE FROM A N OBJECT I CAN USE THE TENTAIVE BUTTON TO PICK A POINT, ENTER THE "X & Y" (& Z) OFFSET DISTANCE THEN PLACE THE FIRST POINT OR OBJECT.

gugg
2015-08-20, 06:15 PM
I'VE BEEN AN AUTOCAD USER SINCE VERSION 2.0 AND AN OWNER SINCE RELEASE 14. (I ACTUALLY HAVE A CPM VERSION 1.0 THAT I FOOLED AROUND WITH IN THE EARLY 80'S.)

SINCE 1984 I'VE BEEN AN AUTOCAD, MICROSTATION, CATIA, PDS, PDMS, PLANT SPACE, COMPUSERVE, SOLIDWORKS, VECTORWORKS, AUTO PLANT AND A DOZEN OTHERS EACH ONE REQUIRED WITH THE PARTICULAR JOB I HAD AT THE TIME. I'VE BEEN MOSTLY TIED AT THE HIP TO AUTOCAD (INCLUDING REVIT).

I WILL TRY THE MODIFIED CODE AND DIG INTO LEGACYCTRLPICK MODES TO SEE IF I CAN EMULATE MY NEEDS. THANKS FOR THE HELP.

rick.feineis
2015-08-20, 06:31 PM
Please take a look at Object Snap Tracking to accomplish this in AutoCAD.

Tom Beauford
2015-08-20, 06:34 PM
THANKS FOR THE LEGACYCTRLPICK SUGGESTION. I'LL LOOK AT THE MODE OPTIONS AND SEE HOW IT HELPS.

THE MAIN PURPOSE OF THE TENTATIVE BUTTON OPTION IN MICROSTATION IS IF I WANT TO PLACE AN ENTITY A CERTAIN "X & Y" DISTANCE FROM A N OBJECT I CAN USE THE TENTAIVE BUTTON TO PICK A POINT, ENTER THE "X & Y" (& Z) OFFSET DISTANCE THEN PLACE THE FIRST POINT OR OBJECT.

Please use sentence case, all caps is considered shouting and offensive in most forums. While not familiar with Microstation what you're talking about sounds similar to AutoCAD's from (http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-A2F8FFFB-EEC4-40A5-AFA5-A44C41E281E5) used To Specify a Point From a Temporary Reference Point. Have you tried the modified code? I could try and modify it some more, just not sure exactly what it was supposed to do.

gugg
2015-08-20, 07:30 PM
Object Snap Tracking IS IT! That is the closest to emulating the MicroStation TENTATIVE button function. Thanks.