Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

My lisp code not working for particular drawing

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Yuvaraju.Dhananjay
864 Views, 5 Replies

My lisp code not working for particular drawing

Friends,

 

The attached code is not working on the attached particular drawing. Anybody please go thru the code and let me know what the changes need to be done. please its very urgent. 

 

What actually lisp works: It will draw a pline(drop) in between the pole and consumer and place the footage by using Object data of both blocks.

 

But it's not working in this particular drawing.

 

 

 

 

(defun c:Test ( / js_pole ent_pole dxf_pole js_consu ent_consu dxf_consu)
  (princ "\nSelect block pole")
  (setq
    js_pole (ssget "_+.:E:S" '((0 . "INSERT") (67 . 0) (410 . "Model") (8 . "CHR_IKE_POLES") (2 . "POLE-TEL,`*U10")))
  )
  (cond
    (js_pole
      (princ "\nSelect block consumer")
      (setq
        ent_pole (ssname js_pole 0)
        dxf_pole (entget ent_pole)
        js_consu (ssget "_+.:E:S" '((0 . "INSERT") (67 . 0) (410 . "Model") (8 . "CHR_IKE_SUB_SYMBOLS") (2 . "`*U3")))
      )
      (cond
        (js_consu
          (setq
            ent_consu (ssname js_consu 0)
            dxf_consu (entget ent_consu)
          )
          (cond
            ((eq (ade_odgetfield ent_pole "Pole_Information_point" "Power_Comp" 0) (ade_odgetfield ent_consu "Customer_Information_poin" "Power_Comp" 0))
              (command "_.pline" "_none" (cdr (assoc 10 dxf_pole)) "_none" (cdr (assoc 10 dxf_consu)) "")
              (if (eq (ade_odgetfield ent_consu "Customer_Information_poin" "Customer_S" 0) "Aerial")
                (command "_.chprop" (entlast) "" "_layer" "CHR_AERIAL_DROP" "_color" "5" "_ltscale" 0.4 "")
                (command "_.chprop" (entlast) "" "_layer" "CHR_BURIED_DROP" "_color" "1" "_ltscale" 0.75 "")
              )
              (command "_.text" "_justify" "_BC" "_none" (mapcar '* (mapcar '+ (cdr (assoc 10 dxf_pole)) (cdr (assoc 10 dxf_consu))) '(0.5 0.5 0.5)) 18.0 (angtos (angle (cdr (assoc 10 dxf_pole)) (cdr (assoc 10 dxf_consu)))) (ade_odgetfield ent_consu "Customer_Information_poin" "Span_Fro00" 0))
              (if (eq (ade_odgetfield ent_consu "Customer_Information_poin" "Customer_S" 0) "Aerial")
                (command "_.chprop" (entlast) "" "_layer" "CHR_AERIAL_DROP_FOOTAGE" "_color" "5" "")
                (command "_.chprop" (entlast) "" "_layer" "CHR_BURIED_DROP_FOOTAGE" "_color" "1" "")
              )
              
            )
            (T (princ "\nBad choice!"))
          )
        )
      )
    )
  )
  (prin1)
)
5 REPLIES 5
Message 2 of 6

 

js_consu (ssget "_+.:E:S" '((0 . "INSERT") (67 . 0) (410 . "Model") (8 . "CHR_IKE_SUB_SYMBOLS") (2 . "`*U6")))

Message 3 of 6

Apparently according to your code the consumer block is called *U3 and there is none in the drawing.

 

(ssget "_+.:E:S" '((0 . "INSERT") (67 . 0) (410 . "Model") (8 . "CHR_IKE_SUB_SYMBOLS") (2 . "`*U3")))

But why the use of unnamed blocks? That is a recipe for disaster if you are asking me.

 

Message 4 of 6

ya friend. it's working fine. Can I know how to change that value "U6" for the particular drawing?.  what "6" indicates?

Message 5 of 6
_gile
in reply to: Yuvaraju.Dhananjay

Hi,

 

"*UX" is the "name" given by AutoCAD to anonymous blocks.

You can replace "`*U6" with "`*U*" to allow the user to select any anonymous block, but you'd have to check if the EffectivName of the selected block reference matches your nee.

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 6
Yuvaraju.Dhananjay
in reply to: _gile

Thank you for the information friend.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report