cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Pre-Defined color for Structure Browser objects

jkiesshauer
6-Contributor

Pre-Defined color for Structure Browser objects

Within the Modeling structure browser you can influence the display of the object names using configured browser views. Such as displaying database attributes instead of instance names.

 

I would like to have the option to highlight objects (parts/assemblies) based on their database attributes. Assuming a part is locked (should be not used by designer anymore) within ModelManager it should be possible to define that the name is displayed within the Structure Browser in red color. Or imported parts are displayed in cyan color etc.

4 REPLIES 4

Hi,

I find this option very helpful too.

We use a little piece of LISP to do this. We evaluate some attributes of the browser objects wich comes from our PDM.

It is very helpful but there are a misbehavior with pseudofolders. The pseudofolders inherit the Color of their owner...

No Idea to solve this Problem.

BrowserColors.JPG

;*********************************************************************************************
; Dateiname     :   SD_Browserfarben_PX.lsp
; Autor         :   wz
; Erstellt      :   10/2015
; ge�ndert      : 
;*********************************************************************************************
; Beschreibung  :  -  Setzt Browserfarben in abh�ngigkeit vom Status in Phoenix/PDM
;         -
;*********************************************************************************************
; �nderungen
;
;*********************************************************************************************

(in-package :teo)
(use-package :oli)

(setf ColorState nil)

; Browserfarbe aendern

(sd-defdialog 'SD_Browserfarben

; :dialog-title "kein Titel notwendig"
 
:dialog-control :sequential
 
:toolbox-button nil

:variables  '(             
            
) ;end variables
  
:ok-action
 
'(progn
  
(if (not ColorState)
  
;;then >> Browser umfaerben
     
(progn
          
(ColorsON)
          
(browserfunk)
          
(sd-browser-exec-cmd "parcel-gbrowser"  :REFRESH-TREE)
          
;;Flag setzen
         
(setf ColorState t)          
      
);;progn
  
;;else >> Browserfarbe wegnehmen

(progn
          
(ColorsOFF)
          
(browserfunk)
          
(sd-browser-exec-cmd "parcel-gbrowser"  :REFRESH-TREE)
          
;;Flag setzen
         
(setf ColorState nil)
     
);;progn
  
);;if
   
   
);end Progn

  
:local-functions
'(
    
(ColorsOFF ()
      
(defun my-color-interrogator (node name)
             
(declare (ignore name))
                  
(let ((objname (BrowserNode-objPath node)))
                       
"#000000"
                  
);;let
      
);;defun
    
);;ColorsOFF



    
(ColorsON ()
      
(defun my-color-interrogator (node name)
             
(declare (ignore name))
                  
(setf name (sd-pathname-to-obj(BrowserNode-objPath node)))
                       
(when (AND name
                             
(OR (sd-inq-part-p name)
                             
(sd-inq-assembly-p name)))
                                       
(cond
                                         
((sd-string= (sd-inq-item-attribute name "PDM-ATTR" :STATUS :attachment :contents) "In Arbeit")    "#0000ff" )    ;; blau                                      
                                         
((sd-string= (sd-inq-item-attribute name "PDM-ATTR" :STATUS :attachment :contents) "Zur Pruefung") "#FF00FF" )    ;: Magenta                                            
                                         
((sd-string= (sd-inq-item-attribute name "PDM-ATTR" :STATUS :attachment :contents) "Vorfreigabe")  "#FF8000" )    ;: orange
                                         
((sd-string= (sd-inq-item-attribute name "PDM-ATTR" :STATUS :attachment :contents) "Freigabe")     "#008000" )    ;: gr�n
                                         
((sd-string= (sd-inq-item-attribute name "PDM-ATTR" :STATUS :attachment :contents) "Gesperrt")     "#FF0000" )    ;: rot
                                         
((sd-string= (sd-inq-item-attribute name "PDM-ATTR" :STATUS :attachment :contents)           nil)  "#000000" )    ;;                                      
                                       
);;conf   
                        
);;when
 
       
);;defun
     
);;

(browserfunk ()
       
(sd-browser-add-interrogator "parcel-gbrowser"
                   
:interrogator-type :text-color
                   
:interrogator-func 'my-color-interrogator)
);endbrowserfunk 


);endlocalfunction 
) ;enddefdialog

AndyPoulsen
12-Amethyst
(To:CADmin)

Hi,

This is an interesting issue.  I hope you don't mind -- I rewrote your code without using the sd-defdialog, which isn't required for something like this. Instead, you can just call a function to turn colors on or off (or toggle on/off).

 

The code below has the pseudo-folders inheriting the color of their children. If you want them to be a different color, uncomment the line that matches the pseudo-folder check.

 

I have added a few comments to describe what the code is doing.  Please let me know if you have any questions.

 

I hope this helps!

 

andy

AI MAXTools, Inc.

 

(in-package :teo) 
(use-package :oli)

(defvar *ColorState* nil)

(defun colors-on ()
(setq *ColorState* t)
(defun my-color-interrogator (node name)
(declare (ignore name))
(let (myobj myattrib children)
(setf myobj (sd-pathname-to-obj (browsernode-objpath node)))
(when (and myobj
(or (sd-inq-part-p myobj)
(sd-inq-assembly-p myobj)))
;; if the object is a pseudo-folder, use its first child object as "myobj"
(when (sd-is-pseudo-folder-node-p (browsernode-nodeid node))
(setq children (sd-query-browser "parcel-gbrowser" :get-children node))
(setq myobj (sd-pathname-to-obj (browsernode-objpath (first children)))))
;; capture the attribute value so we don't have to retrieve it multiple times when testing (faster!)
(setf myattrib (sd-inq-item-attribute myobj "PDM-ATTR" :status :attachment :contents))
(cond
((sd-string= myattrib "In Arbeit") "#0000ff" ) ;; blau
((sd-string= myattrib "Zur Pruefung") "#FF00FF" ) ;: Magenta
((sd-string= myattrib "Vorfreigabe") "#FF8000" ) ;: orange
((sd-string= myattrib "Freigabe") "#008000" ) ;: green
((sd-string= myattrib "Gesperrt") "#FF0000" ) ;: rot
;; uncomment the following line to highlight pseudo-folders separately (red in this case)
;; ((sd-is-pseudo-folder-node-p (browsernode-nodeid node)) "#ff0000")
((sd-inq-part-p myobj) "#0000ff") ;; highlight parts w/o matching attrib in blue
((sd-inq-assembly-p myobj) "#008000") ;; highlight assemblies w/o matching attrib in green
(t "#000000") ;; if nothing above matches
))
))
(sd-browser-exec-cmd "parcel-gbrowser" :REFRESH-TREE)
)

(defun colors-off ()
(setq *ColorState* nil)
(defun my-color-interrogator (node name)
(declare (ignore name))
"#000000")
(sd-browser-exec-cmd "parcel-gbrowser" :REFRESH-TREE)
)

(defun colors-toggle ()
(if *ColorState*
(colors-off)
(colors-on)))

(if *ColorState*
(colors-on)
(colors-off))

;; NOTE: we only need to add the interrogate once, so we'll define a variable to check
;; whether it has been added.

(defvar *colorStateInterrogatorAdded* nil)

(unless *colorStateInterrogatorAdded*
(sd-browser-add-interrogator "parcel-gbrowser"
:interrogator-type :text-color
:interrogator-func 'my-color-interrogator)
(setq *colorStateInterrogatorAdded* t)
)

 

Great thank you!

I just saw your post. Now I'll try to implement that. Thank you for your effort and support ...

 

Best wishes

Stephan

 
Announcements


Top Tags