Property Alteration Definition Samples

AutoCAD Map 3D AutoLISP

Up a level
Property Alteration Definition Samples
 
 

The following examples compose property alteration definitions that use range tables.

(defun c:run_altpsample1 () 
    
   ; Range table for Color is:
   ;   < 15 "green"
   ;   < 20 "yellow"
   ;   otherwise "red"
    
   (ade_rtdefrange 
      "COLOR_RANGE" "Color Range Table" 
      '(
         ("<" 15 "green")
         ("<" 20 "yellow")
         ("otherwise" "" "red")
      )
   )
    
   ; Range table for Text Value is:
   ;   < 15 "Small"
   ;   < 20 "Medium"
   ;   otherwise "Large"
    
   (ade_rtdefrange 
   "TEXT_RANGE" "Text Value Range Table" 
      '(
         ("<" 15 "Small")
         ("<" 20 "Medium")
         ("otherwise" "" "Large")
      )
   )
    
   ; The layer of each object will be used to determine what value 
   ; from the range table is to be used:
    
   ; Clear out any existing alteration definitions:
   (ade_altpclear)
    
   ; Next define the color for the objects being created:
   (ade_altpdefine "color" "(range .layer COLOR_RANGE)")
    
   ; Next define the text object to be created for each entity:
   (ade_altpdefine 
      "textobject"  
      '(
         ("color" "(range .layer COLOR_RANGE)")
         ("textvalue" "(range .layer TEXT_RANGE)")
      )
   )
    
   ; For fill, use the following property alteration functions 
   (ade_altpdefine 
      "hatch"  
      '(
         ("pattern" "(range .layer TEXT_RANGE)")
         ("color" "(range .layer COLOR_RANGE)")
      )
   )
    
   (princ)
)
(defun c:run_altpsample2 () 
    
   ; Range table for pattern is:
   (ade_rtdefrange 
      "PATTERN_RANGE" "Hatch Pattern Range Table" 
      '(
         ("<" 15 "Earth")
         ("<" 20 "Grass")
         ("otherwise" "" "Swamp")
      )
   )
    
   ; Range table for Color is:
   (ade_rtdefrange 
      "COLOR_RANGE" "Color Range Table" 
      '(
         ("<" 15 "green")
         ("<" 20 "yellow")
         ("otherwise" "" "red")
      )
   )
    
   ; Range table for scale is:
   (ade_rtdefrange 
      "SCALE_RANGE" "Hatch Scale Range Table" 
      '(
         ("<" 15 "25")
         ("<" 20 "50")
         ("otherwise" "" "100")
      )
   )
    
   ; Range table for Angle is:
   (ade_rtdefrange 
      "ANGLE_RANGE" "Hatch Angle Range Table" 
      '(
         ("<" 15 "45")
         ("<" 20 "90")
         ("otherwise" "" "0")
      )
   )
   ; The layer of each object will be used to determine which value 
   ; from the range table is to use
    
   ; Clear out any existing alteration definitions:
   (ade_altpclear)
    
   ; For fill, use the following property alteration functions 
   (ade_altpdefine 
      "hatch"  
      '(
         ("pattern" "(range .layer PATTERN_RANGE)")
         ("scale" "(range .layer SCALE_RANGE)")
         ("rotation" "(range .layer ANGLE_RANGE)")
         ("color" "(range .layer COLOR_RANGE)")
      )
   )
    
   (princ)
)
(defun c:run_altpsample3 () 
    
   ; Range table for symbol name is:
   (ade_rtdefrange 
      "SYMBOL_RANGE" "Symbol Name Range Table" 
      '(
         ("<" 15 "Sym1")
         ("<" 20 "Sym2")
         ("otherwise" "" "Sym3")
      )
   )
    
   ; Range table for scale is:
   (ade_rtdefrange 
      "SCALE_RANGE" "Symbol Scale Range Table" 
      '(
         ("<" 15 "5")
         ("<" 20 "10")
         ("otherwise" "" "50")
      )
   )
    
   ; Range table for Color is:
   (ade_rtdefrange 
      "COLOR_RANGE" "Color Range Table" 
      '( 
         ("<" 15 "green")
         ("<" 20 "yellow")
         ("otherwise" "" "red")
      ) 
   )
    
   ; The layer of each object will be used to determine which 
   ; value from the range table to use
   ; Clear out any existing alteration definitions:
   (ade_altpclear)
    
   ; For fill, use the following property alteration functions:
   (ade_altpdefine "blockname" "(range .layer SYMBOL_RANGE)")
   (ade_altpdefine "scale" "(range .layer SCALE_RANGE)")
   (ade_altpdefine "color" "(range .layer COLOR_RANGE)")
    
   (princ)
)