+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 34
  1. #1
    Senior Member lamensterms's Avatar
    Discipline
    Manufacture
    lamensterms's Discipline Details
    Occupation
    Steel Detailer
    Discipline
    Manufacture
    Details
    3D Modelling - Mechanical & Structural 2D Detailing - Shop Drawings
    Using
    AutoCAD 2010
    Join Date
    May 2011
    Location
    Berwick, VIC, Australia
    Posts
    169

    Default LISP for hiding/showing objects...

    Registered forum members do not see this ad.

    Hey guys,

    Been an AutoCAD user for a few years. I am a steel detailer and use add-on programs. Previously I had been using a program called EasySteel – and just recently switched to Prosteel.

    Im trying to create a routine which resembles a utility which EasySteel had – but ProSteel is missing.

    The idea is that I have a bunch of 3D objects within my model – and I like to hide and show each item as I wish. In EasySteel this procedure was executed using layers – but ProSteel requires a different method. ProSteel does have its own hide and show commands, but they aren’t as functional as EasySteel’s was.

    What I would like to achieve is as follows:
    1. - There are multiple objects within a model, and I hide some of them to be able to work with more clarity.
    2. - Using ProSteel’s hide command – any number of obects can be hidden.
    3. - Now… of the objects that are hidden – I would like to be able to select a specific few to show (I do not wish to show ALL hidden objects, but rather show any objects I select, leaving the already showing objects still visible).

    So the procedure would be as follows.
    - 1. Hide some objects.
    - 2. Decide I wish to show SOME of the objects I have hidden.
    - 3. Enable a temporary preview of ALL objects within model – allowing me to select which objects I want to show.
    - 4. Once I have picked the objects to show – the temp preview of the full model is ended, all objects visible before the command are sill visible, as well as any objects I have selected during the temporary preview.

    I have written a LISP routine for this (though it’s a little sloppy) – it does work most of the time.

    Sometimes… the lisp routine does not work though – if I have some objects hidden… then I select objects I wish to show…. ALL objects become visible (not just the ones I select).

    So, can someone please help me refine this routine – or offer me any advice on an alternate method for setting this up?

    The two Prosteel commands used in this routine are:
    - "Ps_Regen" – shows all objects in model (I use this for my temp preview to select which objects to show.
    - "Ps_Hide_exclude” – hides all objects in model except any selected.

    I have attached my routine - and my code is below.


    Thanks for any help.


    Code:
    (defun c:ss (/ pt1 pt2 sset1 sset2)
     (setq pt1 '( -500000000 -500000000 -500000000))
     (setq pt2 '( 500000000 500000000 500000000))
     (command "zoom" "all")
     (setq sset1 (ssget "W" pt1 pt2))
     (command "zoom" "P")
     (command "Ps_Regen")
     (setq sset2 (ssget))
     (command "Ps_Hide_exclude" sset1 sset2 "")
     (princ)
    )



    ShowSteel.LSP

  2. #2
    Senior Member ketxu's Avatar
    Computer Details
    ketxu's Computer Details
    Operating System:
    Sorry, my English not well :(
    Computer:
    Sorry, my English not well :(
    Motherboard:
    Sorry, my English not well :(
    CPU:
    Sorry, my English not well :(
    RAM:
    Sorry, my English not well :(
    Graphics:
    Sorry, my English not well :(
    Primary Storage:
    Sorry, my English not well :(
    Secondary Storage:
    Sorry, my English not well :(
    Monitor:
    Sorry, my English not well :(
    Using
    AutoCAD 2007
    Join Date
    Sep 2010
    Location
    Sorry, my English not well :(
    Posts
    169

    Default

    Just i don't know how you can select ss that hidden ??
    You can use acet-ss-visible to show or hide a specify ss, don't sure that is what you need
    Example :
    Code:
    (setq ss1 (ssget) ss2 (ssget))
      (acet-ss-visible ss1 1) ; hide ss1
      (acet-ss-visible ss2 1) ; hide ss2
      (acet-ss-visible ss1 0) ; un-hide ss1
    So you can improve : unhide all, ssget with method "C","W","CP","WP".., then re-hide all except items you want to show

    (Srr, my English not well)

  3. #3
    Senior Member SunnyTurtle's Avatar
    Computer Details
    SunnyTurtle's Computer Details
    Operating System:
    Win 7 64 bit
    Computer:
    HP 600 Workstation
    CPU:
    Intel(R) Xeon(R) CPU X5650 @ 2.67GHz 2.66GHz
    RAM:
    6GB
    Graphics:
    NVIDIA Quadro FX 4800
    Discipline
    Civil
    SunnyTurtle's Discipline Details
    Occupation
    Drafter CAD Civil
    Discipline
    Civil
    Using
    AutoCAD 2011
    Join Date
    Apr 2011
    Location
    Sydney Australia
    Posts
    112

    Default

    can you explain what an addon to AutoCAD is and how does this program organise the differnet objects but an object name or a difference in entity i.e. layers

    or have i understood your question wrong do you want to click on things and then hide them or want to hide all of a paricutar type on many different dwgs

    also i could write a lisp that would allow you select objects and place them on a hidden layer which you can turn on an off.
    Code:
    (defun nfl ()
      (command: "-layer" "new" "HIDDED" "freeze" "HIDDEN" " ")
      );defun nl
    (defun c:ho ()
      (setq objects (ssget)) ;selects objects
      (nfl)(command: "change" objects "properties" "LAyer" "HIDDEN") ;places objects on a hidden layer
    (see later post by other members for better techniques.)
    this needs a way to unfreeze and place on original layer there is an easy way to do this but i have forgoten
    Last edited by SunnyTurtle; 31st May 2011 at 12:24 am. Reason: add,

  4. #4
    Senior Member lamensterms's Avatar
    Discipline
    Manufacture
    lamensterms's Discipline Details
    Occupation
    Steel Detailer
    Discipline
    Manufacture
    Details
    3D Modelling - Mechanical & Structural 2D Detailing - Shop Drawings
    Using
    AutoCAD 2010
    Join Date
    May 2011
    Location
    Berwick, VIC, Australia
    Posts
    169

    Default

    ketxu

    The way i create a selection set from hidden objects - is that i temporarily show all objects, then select items i want shown, then the preview ends and i am left with objects i selected during the preview as well as the objects i had shown before i began the 'show' command - and the objects i didnt select are hidden.

    can you please explain the 'acet-ss-visible' function?


    SunnyTurtle

    Im not exactly sure how prosteel hides and shows objects (ive heard its to do with the DXF display mode... but i really dont know) - it is not with layers though. I have written a routine that will do what i need (by moving objects to frozen/off layers) but i would rather not do it this way. The problem would be that i have lots of objects on many different layers. So in order to hide any object i would have to move it onto a frozen/off layer - but then i would like to restore it to its original layer (the layer it was on before it was hidden.

    for example... if i have 2 objects in my model - 1 beam and 1 column... the beam is on a layer called "BEAM" and the column is on a layer called "COLUMN". I could hide these 2 objects by moving them both onto a layer called "HIDDEN" and having the "HIDDEN" layer turned off or frozen. But then when i wish to have these 2 objects un-hidden (shown)... how could i restore the beam to the "BEAM" layer and the column to the "COLUMN" layer.


    thanks for your help guys.
    Last edited by lamensterms; 30th May 2011 at 07:12 am.

  5. #5
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,953

    Default

    If I were to take a stab at this....

    I'd first make selection set of the objects to hide, and store the vla-objects to a global variable as a list, then set the visible property to :vlax-false. To unhide only a selection within the original hidden group, I'd restore the visibility to :vlax-true, but modify their color so they stand out visually. Any objects selected would be stored to a list and if vl-position the item in the hidden list, unhide, and remove from the list.

    Note - Good *error* handling, and a reactor are needed in order to prevent accidental saving etc. of the drawing with objects hidden. Also do not forget to account for UNDO.
    "Potential has a shelf life." - Margaret Atwood

  6. #6
    Senior Member lamensterms's Avatar
    Discipline
    Manufacture
    lamensterms's Discipline Details
    Occupation
    Steel Detailer
    Discipline
    Manufacture
    Details
    3D Modelling - Mechanical & Structural 2D Detailing - Shop Drawings
    Using
    AutoCAD 2010
    Join Date
    May 2011
    Location
    Berwick, VIC, Australia
    Posts
    169

    Default

    hey RenderMan,

    thanks for the reply mate. Im afraid i am quite new and very inexperienced when it come to LISP. Many (if not all) of my routines are just compilations of other routines and i know very little about lists and such.

    Having said that... my experience is limited to AutoLISP - and i know nothing about VLISP and the macros.

    Error handling and reactors are also beyond me - my routine does fail miserably if i escape out of it or select no objects to show... but i can undo back though the command.

    Ive still got a lot to learn.

    Thanks again.

  7. #7
    Senior Member ketxu's Avatar
    Computer Details
    ketxu's Computer Details
    Operating System:
    Sorry, my English not well :(
    Computer:
    Sorry, my English not well :(
    Motherboard:
    Sorry, my English not well :(
    CPU:
    Sorry, my English not well :(
    RAM:
    Sorry, my English not well :(
    Graphics:
    Sorry, my English not well :(
    Primary Storage:
    Sorry, my English not well :(
    Secondary Storage:
    Sorry, my English not well :(
    Monitor:
    Sorry, my English not well :(
    Using
    AutoCAD 2007
    Join Date
    Sep 2010
    Location
    Sorry, my English not well :(
    Posts
    169

    Default

    I've posted but it doesn't display, so i re-post. If it duplicate, please del ^^
    Use :
    Code:
     (acet-ss-visible ss flag)
     - ss :  Selection set
     - flag : accept two value
             + 0 : visible SS
             + 1 : invisible SS
    Remember that you've installed Express for using ACET-*** functions
    - You can use acet-ss-redraw
    Code:
    (acet-ss-redraw ss flag)
    - ss : Selection set
    -  flag : 
      + 1 : show normal
      + 2 : invisible SS
      + 3 :  highlight SS
      + 4 : un-highlight
    So you can start ur idea now, just working with SS ^^

  8. #8
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,633

    Default

    A documented function .

    Code:
    (vla-put-visible <vla-object> :vlax-false)
    
    (vla-put-visible <vla-object> :vlax-true)
    Tharwat

  9. #9
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,926

    Default

    Here are 3 functions that should work:


    Code:
    ;+++++++++++++ Hide Selected Entites +++++++++++++++++++++++++++++
    (defun c:hse (/ ss en ed)
      (and (not (tblsearch "APPID" "HIDE"))
           (regapp "HIDE"))
      (if (not (tblsearch "LAYER" "HIDE"))
          (command "_.LAYER" "_New" "HIDE" "_F" "HIDE" ""))
      (if (/= (getvar "CLAYER") "HIDE")
          (command "_.LAYER" "_Freeze" "HIDE" "")
          (command "_.LAYER" "_UnLock" "0" "_ON" "0" "_Thaw" "0" "_Set" "0"
                             "_Freeze" "HIDE" ""))
      (princ "\nSelect Entities To Make InVisible")
      (and (setq ss (ssget (list (cons 8 "~HIDE"))))
           (while (setq en (ssname ss 0))
                  (setq ed (entget en))
                  (add_xdata_str en "HIDE" (cdr (assoc 8 ed)))
                  (ssdel en ss)
                  (command "_.CHPROP" en "" "_LAyer" "HIDE" "")))
      (prin1))
    
    ;+++++++++++++ Restore ALL HIDE Layer Entities To Original Layer +++++
    (defun c:rae (/ ss en xl0 xl1 xl2 xl3)
      (and (setq ss (ssget "X" (list (cons 8 "HIDE"))))
           (while (setq en (ssname ss 0))
                  (setq xl0 (entget en '("HIDE"))
                        xl1 (cdr (assoc -3 xl0))
                        xl2 (cdr (assoc "HIDE" xl1))
                        xl3 (cdr (assoc 1000 xl2)))
                  (command "_.CHPROP" en "" "_LA" xl3 "")
                  (ssdel en ss)))
      (prin1))
    
    ;+++++++++++++ Restore Partial HIDE Layer Entities To Original Layer +++++
    (defun c:rpe (/ ss en xl0 xl1 xl2 xl3)
      (if (not (tblsearch "LAYER" "HIDE"))
          (alert "There are no hidden entities on layer HIDE")
          (progn
            (command "_.LAYER" "_T" "HIDE" "")
            (princ "\nSelect Hidden Entities To Make Visible")
            (and (setq ss (ssget (list (cons 8 "HIDE"))))
                 (while (setq en (ssname ss 0))
                        (setq xl0 (entget en '("HIDE"))
                              xl1 (cdr (assoc -3 xl0))
                              xl2 (cdr (assoc "HIDE" xl1))
                              xl3 (cdr (assoc 1000 xl2)))
                        (command "_.CHPROP" en "" "_LA" xl3 "")
                        (ssdel en ss)))
            (command "_.LAYER" "_F" "HIDE" "")))
      (prin1))
    
    ;++++++++++++ Add XDATA String To An Entity ++++++++++++++++++++++
    (defun add_xdata_str (e a v);;;EName APPID String_value
      (and (= (type a) 'STR)
           (not (tblsearch "APPID" a))
           (regapp a))
      (and (= (type e) 'ENAME)
           (= (type v) 'STR)
           (entmod
             (append (entget e)
               (list
                (cons -3
                 (list
                  (cons a
                   (list (cons 1000 v))))))))))

    Be sure to load the entire code as add_xdata_str is a global function.

    Hopefully, you are not using a layer named HIDE in other scenarios. This allows for the selections to carried from 1 acad session to another.

    Adding an error trap and sysvar mode setting would be advisable for a robust routine. -David
    R12 (Dos) - A2K

  10. #10
    Senior Member kruuger's Avatar
    Computer Details
    kruuger's Computer Details
    Operating System:
    Xp 64bit
    Using
    AutoCAD 2010
    Join Date
    Dec 2007
    Location
    Poland
    Posts
    181

    Default

    Registered forum members do not see this ad.

    that's very clever David. i like it.
    replace command with vla and will be perfect
    kruuger

Similar Threads

  1. All objects in drawing not hiding?
    By Mason Dixon in forum AutoCAD 3D Modelling & Rendering
    Replies: 11
    Last Post: 12th May 2011, 11:30 pm
  2. Hiding 3d objects when plotting
    By noxit in forum AutoCAD 3D Modelling & Rendering
    Replies: 4
    Last Post: 11th Feb 2011, 10:00 pm
  3. Showing and Hiding AutoCAD Toolbars
    By CAD Panacea in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 6th Jan 2010, 06:20 pm
  4. Hiding some objects
    By alijahed in forum AutoCAD General
    Replies: 9
    Last Post: 25th Jun 2008, 05:51 am
  5. Hiding objects in viewport
    By f700es in forum AutoCAD Drawing Management & Output
    Replies: 11
    Last Post: 24th Jun 2003, 01:05 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts