LISP ROUTINE - Merge Multiple LISPs

LISP ROUTINE - Merge Multiple LISPs

emreakyazicigsl
Advocate Advocate
799 Views
2 Replies
Message 1 of 3

LISP ROUTINE - Merge Multiple LISPs

emreakyazicigsl
Advocate
Advocate

Hey everyone, thanks to @Z9E3zK5E, I obtained a LISP that inserts blocks by predetermining dynamic properties and attributes. For further step, I have a basic second command which creates lines according to insert point.

 

How can I merge these commands, according to insert point and previous LISP? I tried a little but, couldn't manage. I hope you may help. Thank you.

;INSERT BLOCKS
;Thanks to @ВeekeeCZ

(vl-load-com)

(defun c:144 ( / o dynprops atvalues)

(defun dtr (a)
(* pi (/ a 180.0))
)
(setq ang1 (dtr 25.0))


  (command-s "_.-insert" "BLOCKNAME1" "_b" "0,-10" "_s" 1 "_r" 0)

  (setq dynprops (list

		   (cons "Angle1" ang1) 

		   '("Position1 X" . 10)			; all dyn-values are numbers - without ""
		   '("Position1 Y" . 10)

		   '("Position2 X" . 20)			; all dyn-values are numbers - without ""
		   '("Position2 Y" . 20)

		   '("Position3 X" . 30)			; all dyn-values are numbers - without ""
		   '("Position3 Y" . 30)

		   '("Position4 X" . 40)			; all dyn-values are numbers - without ""
		   '("Position4 Y" . 40)

		   )
	
	atvalues '(
			("TAG1" . "VALUE11")
			("TAG2" . "VALUE22")
			("TAG3" . "VALUE33")
			("TAG4" . "VALUE44")


		   ))
	
  (setq o (vlax-ename->vla-object (entlast)))
  (LM:setdynprops o dynprops)
  (LM:vl-setattributevalues o atvalues)

  (princ)
)



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Set Dynamic Block Properties  -  Lee Mac
;; Modifies values of Dynamic Block properties using a supplied association list.
;; blk - [vla] VLA Dynamic Block Reference object
;; lst - [lst] Association list of (( . ) ... )
;; Returns: nil

(defun LM:setdynprops ( blk lst / itm )
    (setq lst (mapcar '(lambda ( x ) (cons (strcase (car x)) (cdr x))) lst))
    (foreach x (vlax-invoke blk 'getdynamicblockproperties)
        (if (setq itm (assoc (strcase (vla-get-propertyname x)) lst))
            (vla-put-value x (vlax-make-variant (cdr itm) (vlax-variant-type (vla-get-value x)))))))

;; Set Attribute Values  -  Lee Mac
;; Sets attributes with tags found in the association list to their associated values.
;; blk - [vla] VLA Block Reference Object
;; lst - [lst] Association list of (( . ) ... )
;; Returns: nil

(defun LM:vl-setattributevalues ( blk lst / itm )
    (foreach att (vlax-invoke blk 'getattributes)
        (if (setq itm (assoc (vla-get-tagstring att) lst))
            (vla-put-textstring att (cdr itm)))))

 

 

;LINE LISP

(defun c:S1 ( / p1 p2 p3 p4)
    (setq p1 (getpoint "\nLine origin: "))

    (setq p2 (mapcar '+ p1 '(5 5 0)))
    (setq p3 (mapcar '+ p1 '(0 -5 0)))
    (setq p4 (mapcar '+ p3 '(60 0 0)))
    (setq p5 (mapcar '+ p3 '(-60 0 0)))

    (setq p10 (mapcar '+ p2 '(5 -5 0)))
    (setq p20 (mapcar '+ p10 '(5 0 0)))
    (setq p30 (mapcar '+ p20 '(0 50 0)))

    (setq p102 (mapcar '+ p1 '(-5 5 0)))
    (setq p110 (mapcar '+ p102 '(-5 -5 0)))
    (setq p120 (mapcar '+ p110 '(-5 0 0)))
    (setq p130 (mapcar '+ p120 '(0 50 0)))

  (entmakex (list '(0 . "LINE")(cons 10 p1)(cons 11 p3)))
  (entmakex (list '(0 . "LINE")(cons 10 p3)(cons 11 p4)))
  (entmakex (list '(0 . "LINE")(cons 10 p3)(cons 11 p5)))

  (entmakex (list '(0 . "LINE")(cons 10 p2)(cons 11 p10)))
  (entmakex (list '(0 . "LINE")(cons 10 p10)(cons 11 p20)))
  (entmakex (list '(0 . "LINE")(cons 10 p20)(cons 11 p30)))

  (entmakex (list '(0 . "LINE")(cons 10 p102)(cons 11 p110)))
  (entmakex (list '(0 . "LINE")(cons 10 p110)(cons 11 p120)))
  (entmakex (list '(0 . "LINE")(cons 10 p120)(cons 11 p130)))
)

 

0 Likes
Accepted solutions (1)
800 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution

 Autocad stores the last point from his core commands (as INSERT is) in the  LASTPOINT system variable. So... use it.

 

(setq p1 (getvar 'lastpoint))

 

0 Likes
Message 3 of 3

emreakyazicigsl
Advocate
Advocate

Oh, thank you so much.

0 Likes