"Zoom object" via Lisp?

I want to define an object with
(setq myobject (entlast))

And then I want to zoom to this object:
(command "_zoom" "_object" myobject)

But I get an error because it asks also for a point. So - how to zoom to an object via Lisp?

Comments

  • Put myobject into a selectionset an pass it to zoom command:
    (command "_zoom" "_object" (ssadd myobject) "")

  • Thanks - works fine!

  • I think the problem with the original code is the missing Enter that concludes the selection.
    This works fine:
    (command "_zoom" "_object" myobject "")

  • I think an option to zoom to selected objects should be a default tool
    or behavior in a 3D CAD App.
    And all tools to control view window should work without interrupting
    any commands.
    (And view changes need to be external from Undo History and need their
    own View Undo History)

    So for Zoom_e
    (the only fit view command I ever use)
    When something is selected, it should zoom to selected entities,
    if nothing selected, it should zoom to all entities visible.
    (One can argue if locked geometry is ignored or not)

  • zoom to selected objects

    I use that a lot.
    (defun c:ZS () (princ "Select objects to zoom to: ") (setq ss1 (ssget)) (command "ZOOM" "OBject" ss1 "") )

    When something is selected, it should zoom to selected entities,
    if nothing selected, it should zoom to all entities visible.

    VectorWorks does that. I really liked that feature.
    Here's a custom command I just wrote that so far seems to work:
    (defun c:ZE () (if (setq ss1 (ssget "_I")) (command "ZOOM" "OBject" ss1 "") (command "ZOOM" "Extents") ) )

    I work in a pseudo-VectorWorks mode, in which selection sets remain selected after an editing command and new entities created by a drawing command become the new selection set. So I add this line to just before the end of each of those custom commands:
    (if ss1 (sssetfirst nil ss1))

  • Thanks Anthony.
    I'm still learning Bricscad, Lisp is far too much for me at the moment.
    But I really like your attempt to force Bricscad into a VW mode.
    In case of Fit View and Selection I think this is clearly the better behavior.
    (+ Num keys to switch view orientations, as long as no DynDim active)

    Yes, also use mainly VW so far.
    But I would say such behavior is not just VW,
    it is more like a quasi standard in most 3D or CAD Apps that I currently
    use or have used in the past. From my view only ACAD is the exotic solution.

    Did you add the "bring back selection Lisp" to all commands
    by a custom partial CUI ?

  • Anthony Apostolaros
    edited January 2018

    I do have a few custom pull-down menus in my CUI. One is for rarely-used custom commands. Another is for variables, and a third is for scales. But I execute most commands by typing one or two letters plus the space bar. I can't get rid of the space bar, but I have completely eliminated L's and P's.

    I used lisp to make custom versions of all the commands I normally use. Most of them are just the built-in command but terminating with a selection set that's highlighted and ready to be used as the preselection for the next command. For editing commands, I do that by ending the lisp function with (sssetfirst nil (ssget "P")), so that whatever was highlighted before the command is also highlighted afterward. For commands that create new entities, I get the number of the last entity created, then execute the command, then select and highlight all the entities with numbers higher than that.

    Some of my commands are more customized. They're combinations of a built-in command plus one or more option letters, so that the command normally behaves the way I normally want it to. So, for example, my Break command expects me to select an object and then pick the break point, as in VW. My Join command just converts all the coterminal lines, arcs, and polylines in the selection set into a single polyline. My Scale command expects me to pick 3 points -- the base point and then the from and to points for the change in size, as in VW. My Rotate command similarly expects 3 points -- the fulcrum point and then the from and to points of the rotation, just as in VW. And I have a function key that makes the selection set rotate 90 degrees around its centroid each time I press it. And my Home key gives me a Zoom Extents and my End key gives me Zoom Previous.

    Of course I work with PickAdd turned off, so that selecting anything deselects everything else unless the shift key is held down. And I always create the selection set before executing the command. And I use a lot of polylines, and I use byentity rather than bylayer color and lineweight, and I have a set of two-letter commands that filter a selection set for color, lineweight, layer, entity type, etc, so that I rarely have to use anything but a single window or crossing and maybe a filter to get the selection set I want.

  • Thanks Anthony.

    That all sounds exactly like I would like to work in Bricscad.

    Not to be misunderstood, if everything in VW would be golden,
    I would not bother with a BIM license and this Forum.
    But things like losing Selections or a Rectangle Tool that has to be
    reactivated each time again doesn't make much sense to me.

    Your descriptions sound a bit like that is not something I could simply
    send a Feature Request for an Option in Settings, like PickAdd off,
    more like a complete branch of Bricscad) with modifications for
    each single command (?)

    So I should learn to do the same as you did, customize each command.
    I see that I could add modifications in the Command Row in
    Tools > Customize > Toolbars > my custom Partial CUI Toolboxes
    Is this the right place ?

    BTW,
    did you also something to clear selection with a single LMB click into
    blank drawing window ?

  • No, unfortunately, I haven't found a way to make clicking on blank space in the drawing window deselect all, nor to make clicking on one entity in a selection set deselect all the others. I use the F12 key, which I have macro'd to equal the Esc key. If you mouse with your right hand you can just use Esc. I also have (sssetfirst nil nil) as the first command in my "Edit" context menu, but I never use it. My right hand is always roaming between the letter keys and the numeric keypad, so it's never far away from F12.

    You can turn Pickadd off just by typing pickadd off , or you can use this custom command that toggles it on or off:
    (defun c:Add () (sssetfirst nil nil) (if (= (getvar "PICKADD") 0) (progn (setvar "PICKADD" 1) (princ "PICKADD = Add to selection set.")) (progn (setvar "PICKADD" 0) (princ "PICKADD = Don't add to selection set.")) ))

    You can do some customizing in the Customize palette. I don't do that because I don't use toolbars or menu commands. I think you can add Select;P; after each editing command to get the selection set back. And I think Select;L; after a drawing command will select and highlight one of the new entities created, so that would work for the Rectang command. And I believe you can add option letters. Beyond that, I think you need to use lisp or one of the other programming languages. You're welcome to use all the custom commands that I've created in Lisp. It'll be easy to see how to modify them, or to create others similar to them. If you're interested, I'll gather them into a file and post it.

This discussion has been closed.