Author Topic: Visible value true or false  (Read 2042 times)

0 Members and 1 Guest are viewing this topic.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Visible value true or false
« on: December 04, 2015, 04:30:09 AM »
Hello!
I have written some rows to can select a PipeObject (AeccDbPipe) in Civil3d and freeze them.
My Problem is I didnīt find anything in Civil3d to unfreeze same object, because I can not select them (isnīt visible).
Here a test
Code: [Select]
(if (setq e (entsel "\n Select Pipe Object!"))
    (progn
      (setq vEnt (vlax-ename->vla-object (car e)))
      (cond
((= (vla-get-objectname vEnt) "AeccDbGraphProfileNetworkPart")
(setq desc (vlax-get-property vEnt 'Description))
(setq disp (vlax-get-property vEnt 'DisplayName))
(alert (strcat
  "\nDescription: " desc
  "\nName: " disp
  )
)
)
((= (vla-get-objectname vEnt) "AeccDbPipe")
(setq desc (vlax-get-property vEnt 'Description))
(setq disp (vlax-get-property vEnt 'DisplayName))
(alert (strcat
  "\nPipe"
  "\nDescription: " desc
  "\nName: " disp
  )
)
)
((= (vla-get-objectname vEnt) "AeccDbStructure")
(setq desc (vlax-get-property vEnt 'Description))
(setq disp (vlax-get-property vEnt 'DisplayName))
(alert (strcat
  "\nStructure"
  "\nDescription: " desc
  "\nName: " disp
  )
)
)
);cond
      (if (and desc disp)
(progn
  (initget "YES NO")
  (setq r (getkword "\n Freeze object? [<Yes> / No]: "))
  (cond
    ((or (= r "YES")(null r))
     (princ (strcat "\nObject " disp " freezed."))
     (vlax-put-property vEnt 'Visible :vlax-false)
     )
    ((= r "NO")
     (princ "Do nothing.")
     )
    )
  )
)
      )
    )

Annother Problem is if I mark to inspect vla-object AeccDbPipe in vlide-console
mark: variable vEnt + Rightclick (Inspect)
or
mark: (vlax-ename->vla-object (car e))  + Rightclick (Inspect)

I get a error message, which I donīt understand
; error: ActiveX Server returned an error: Bad variable type

kpblc

  • Bull Frog
  • Posts: 396
Re: Visible value true or false
« Reply #1 on: December 04, 2015, 04:42:31 AM »
What about vlax-dump-object? And did you loaded ObjectEnablers (demandload = 3 ot not)?
Sorry for my English.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Visible value true or false
« Reply #2 on: December 04, 2015, 04:47:17 AM »
To select invisible objects:
Code - Auto/Visual Lisp: [Select]
  1. (ssget "_X" '((60 . 1)))

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Visible value true or false
« Reply #3 on: December 04, 2015, 04:56:06 AM »
(demandload = 3)
what does it mean (demandload value 3... contains custom or when you invoke on of the applications commands)
vlax-dump-objects works fine

inspect request works with normaly Acadobjects (line, arc, circle...) yesterday it works also by AeccDbPipe-objects from Civil but today I get error-message

This solution unfreeze all Pipes in drawing, but itīs not so usefull, I want select on screen in ca. position or type a name, maybe some Civil-guys have a better way to do that.

Code: [Select]
(if (setq ss (ssget "X" '((8 . "VA-LEDN"))))
    (progn
      (repeat (sslength ss)
(setq vEnt (vlax-ename->vla-object (ssname ss (setq i (1+ i)))))
(vlax-put-property vEnt 'Visible :vlax-true)
(cond
  ((= (vla-get-objectname vEnt) "AeccDbPipe")
   (setq desc (vlax-get-property vEnt 'Description))
   (setq disp (vlax-get-property vEnt 'DisplayName))
   (princ (strcat
  "\nPipe"
  "\nDescription: " desc
  "\nName: " disp
  )
)
   (setq z (1+ z))
   )
  )
)
      (alert (strcat (itoa z) " Pipes found on Layer 'VA-LEDN'"))
      )
    )

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Visible value true or false
« Reply #4 on: December 04, 2015, 05:11:02 AM »
this is even better, but I continue wondering, why Civil doesnīt have a command for this unfreeze or freeze-function
Code: [Select]
(defun c:showAll()
  (if (setq req (strcase (getstring "\nGet a Pipetype [Vatten / Spill / Dag]")))
    (cond
      ((or (= req "V")(= req "VATTEN"))
       (setq s "V")
       )
      ((or (= req "S")(= req "SPILL"))
       (setq s "S")
       )
      ((or (= req "D")(= req "DAG"))
       (setq s "D")
       )
      )
    )
 
  (setq i -1 z 1)
  (if (setq ss (ssget "X" '((8 . "VA-LEDN"))))
    (progn
      (repeat (sslength ss)
(setq vEnt (vlax-ename->vla-object (ssname ss (setq i (1+ i)))))
(cond
  ((= (vla-get-objectname vEnt) "AeccDbPipe")
   (setq desc (vlax-get-property vEnt 'Description))
   (setq disp (vlax-get-property vEnt 'DisplayName))

   (if (vl-string-search s desc)
     (progn
       (princ (strcat
"\nPipe"
"\nDescription: " desc
"\nName: " disp
)
      )
       (setq z (1+ z))
       (vlax-put-property vEnt 'Visible :vlax-true)
       )
     )
   
   )
  )
)
      (alert (strcat (itoa z) " Pipes found on Layer 'VA-LEDN'"))
      )
    )
  (princ)
  )

kpblc

  • Bull Frog
  • Posts: 396
Re: Visible value true or false
« Reply #5 on: December 04, 2015, 06:25:15 AM »
I'm not use Civil, so i can't check code:
Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun test (/ ent_lst layer str fun_get-prop)
  3.  
  4.   (defun fun_get-prop (obj prop)
  5.     (if (vlax-property-available-p obj prop)
  6.       ""
  7.       ) ;_ end of if
  8.     ) ;_ end of defun
  9.  
  10.  
  11.              (setq str
  12.                     (vl-catch-all-apply
  13.                       (function
  14.                         (lambda (/ res)
  15.                           (initget 1 "Vatten Spill Dag _ V S D")
  16.                           (getkword "\nGet a Pipetype [Vatten/Spill/Dag] <Cancel> : ")
  17.                           ) ;_ end of lambda
  18.                         ) ;_ end of function
  19.                       ) ;_ end of vl-catch-all-apply
  20.                    ) ;_ end of setq
  21.              ) ;_ end of vl-catch-all-error-p
  22.            ) ;_ end of not
  23.     (progn
  24.       (setq layer (strcase "VA-LEDN"))
  25.         (if (and (= (strcase (vla-get-layer ent) layer)
  26.                     (= (vla-get-objectname ent) "AeccDbPipe")
  27.                     ) ;_ end of =
  28.                  ) ;_ end of and
  29.           (setq ent_lst (cons ent ent_lst))
  30.           ) ;_ end of if
  31.         ) ;_ end of vlax-for
  32.       ) ;_ end of progn
  33.     (if ent_lst
  34.       (progn
  35.         (princ (apply (function strcat)
  36.                       (mapcar
  37.                         (function
  38.                           (lambda (x)
  39.                             (strcat "\nPipe:"
  40.                                     (mapcar
  41.                                       (function
  42.                                         (lambda (a)
  43.                                           (strcat "\n\t" a (fun_get-prop x a))
  44.                                           ) ;_ end of lambda
  45.                                         ) ;_ end of function
  46.                                       '("Description" "Name")
  47.                                       ) ;_ end of mapcar
  48.                                     ) ;_ end of strcat
  49.                             ) ;_ end of lambda
  50.                           ) ;_ end of function
  51.                         ent_lst
  52.                         ) ;_ end of mapcar
  53.                       ) ;_ end of apply
  54.                ) ;_ end of princ
  55.         (alert (itoa (length ent_lst) " pipes found on layer " layer))
  56.         ) ;_ end of progn
  57.       (alert "No pipes found")
  58.       ) ;_ end of if
  59.     ) ;_ end of if
  60.   (princ)
  61.   ) ;_ end of defun
Sorry for my English.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Visible value true or false
« Reply #6 on: December 04, 2015, 08:00:27 AM »
Looking interesting. I get some mistake, but so it works...
Itīs not really solution of in my case, but thanks for your nice work, I learned more about lambda
Code: [Select]
(vl-load-com)
 
(defun c:test (/ ent_lst layer str fun_get-prop)
 
  (defun fun_get-prop (obj prop)
    (if (vlax-property-available-p obj prop)
      (vl-princ-to-string (vlax-get-property obj prop))
      ""
      ) ;_ end of if
    ) ;_ end of defun
 
 
  (if (not (vl-catch-all-error-p
             (setq str
                    (vl-catch-all-apply
                      (function
                        (lambda (/ res)
                          (initget 1 "Vatten Spill Dag _ V S D")
                          (getkword "\nGet a Pipetype [Vatten/Spill/Dag] <Cancel> : ")
                          ) ;_ end of lambda
                        ) ;_ end of function
                      ) ;_ end of vl-catch-all-apply
                   ) ;_ end of setq
             ) ;_ end of vl-catch-all-error-p
           ) ;_ end of not
    (progn
      (setq layer (strcase "VA-LEDN"))
      (vlax-for ent (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
        (if (and (= (strcase (vla-get-layer ent)) layer)
                    (= (vla-get-objectname ent) "AeccDbPipe")
                    ) ;_ end of =
          (setq ent_lst (cons ent ent_lst))
          ) ;_ end of if
        ) ;_ end of vlax-for
      ) ;_ end of progn
    )
 
    (if ent_lst
      (progn
        (princ (apply (function strcat)
      (mapcar
                        (function
                          (lambda (x)
                            (vl-princ-to-string
                                    (mapcar
                                      (function
                                        (lambda (a)
                                          (strcat "\n\t" a ": " (fun_get-prop x a))
                                          ) ;_ end of lambda
                                        ) ;_ end of function
                                      '("Description" "Name")
                                      ) ;_ end of mapcar
      )
                            ) ;_ end of lambda
                          ) ;_ end of function
                        ent_lst
                        ) ;_ end of apply
      )
               ) ;_ end of princ
        (alert (strcat (itoa (length ent_lst)) " pipes found on layer " layer))
        ) ;_ end of progn
      (alert "No pipes found")
      ) ;_ end of if
  (princ)
  ) ;_ end of defun