January 28, 2017

Seek-ing Content?

If you made use of the Autodesk® Seek, you should know that as of January 16*, 2017, that service has been transferred to BIMobject® Cloud Solution. Links to Autodesk Seek will be redirected to BIMObject. Read more about the transfer in this Autodesk Knowledge Network article. Read more about BIMobject Cloud solution at the BIMobject website.

* - or, perhaps January 18, depending upon whether the date in the AKN article or redirect dialog is correct.

January 18, 2017

AutoLISP: Selecting-Gripping Objects by Handle

The AutoCAD® Architecture SHOWDISPLAYOVERRIDES command is a great way to find objects that have a style- or object-level display override associated with them. At least, in a relatively small file it is. Running the command allows you to select either type of override or both, and it will list the objects at the command line as well as highlight them in the drawing canvas. If your drawing extents are fairly tight, you may be able to start zoomed all of the way out and still see the highlighted objects. But if your drawing extents are larger, then it will be hard to see the highlighting when zoomed out. Unfortunately, the command does not actually select the items, or activate the grips on them. You can use the mouse wheel to zoom in afterwards without losing the highlights, but unless you know where to look, that can be frustrating.

The command line output lists the Display Representation with the override, the override type, the object type and the handle of the object for object-based overrides or the handle of the style for style-based overrides.
Command: SHOWDISPLAYOVERRIDES
Show Display Overrides [byObject/byStyle/Both]: b
Massing Element Display Representation Plan High Detail Object based override found on Mass Element ("460F")
Massing Element Display Representation Plan High Detail Style based override found on Mass Element Style "Standard (2)" ("461C")
Massing Element Display Representation Plan High Detail Object based override found on Mass Element ("4733")
Massing Element Display Representation Plan High Detail Object based override found on Mass Element ("4737")

I wrote a quick AutoLISP® routine that will allow me to type in the handles given for the object-based overrides, that will then select and grip these objects. Provided you do not exceed the maximum number of objects for which AutoCAD will show grips at one time (GRIPOBJLIMIT system variable), you should be able to see where the objects that have been gripped are, even when zoomed out. Please note that you should NOT enter the handle of a Style-based override, as there is no graphical object which can be gripped in that case, and the SSFIRSTSET function will throw an error and crash the routine. A test for that could be added, prior to adding the entity to the selection set, but given the manual nature of entering the handles, I did not think that was necessary here.
(defun C:SELHAND (   ; No arguments.
    / ;_ Local variables:
    ename   ; Entity name of object with entered handle [entity name].
    sHand   ; User entered string of object handle [string].
    ss1   ; Selection set of objects whose handles were entered [selection set].
    ) ;_ End arguments and local variables.
  (setq ss1 (ssadd))   ; Initialize ss1 as an empty selection set.
  ;; Ask user for handle strings, until a null response is received.
  (while (/= "" (setq sHand (getstring "\nEnter handle string: ")))
    (setq ename (handent sHand)) ; Try to get entity name from handle string.
    (if ename    ; If an entity was found...
      (setq ss1 (ssadd ename ss1)) ; ...add entity to selection set.
      (prompt    ; ...else, report failure to find object.
 (strcat
   "\nNo entity with handle -->"
   sHand
   "<-- found. "
 ) ;_ End strcat.
      ) ;_ End prompt.
    ) ;_ End if.
  ) ;_ End while.
  (if (> (sslength ss1) 0)  ; If at least one valid handle was entered...
    (sssetfirst nil ss1)  ; ...select item(s), turning on grips.
    (prompt "\nNo valid handles entered.  Nothing to do! ")
     ; ...else, notify user.
  ) ;_ End if.
  (prin1)
) ;_ End C:SELHAND.

January 09, 2017

AutoLISP: Pickable Command Line Options

AutoLISP® code has long supported the use of keywords with many of the GETxxx functions, to allow the user to specify a command-line option rather than provide the input expected by the particular GETxxx function being used, just like AutoCAD commands. The INITGET function is used, prior to the GETxxx function, to specify the keywords. Several releases back, Autodesk made enhancements to the AutoCAD® command line, one of which allowed for using the mouse to click on a command-line option instead of typing at the keyboard. This was also supported in AutoLISP, and I had used it multiple times.

Over the weekend, I was working on a "quick" personal project in AutoLISP, and I wanted to include pickable keywords. The problem was, I had forgotten the syntax for setting those up, and it took me longer than it should have to both realize the problem I was having was due to improper syntax and to find the correct syntax. To save myself time when that happens the next time (and, I suspect, it will), I am documenting the proper syntax here. I had remembered that the keywords needed to be enclosed in square brackets, but forgotten about separating them with forward slashes. I wrote a quick test function, to verify that the problem was in fact with the GETxxx function message formatting; here is the final, corrected code with the correct syntax:
(defun C:TestKW ( / sKW)
  (initget 1 "Alpha Beta Delta")
  (setq sKW (getkword "\nChose a keyword [Alpha / Beta / Delta]: "))
  (prompt (strcat "\nKeyword selected is -->" sKW "<-- "))
  (prin1)
) ;_ C:TestKW.