Jump to content

Insert dynamic block,error: bad argument type: lentityp nil


liuhaixin88

Recommended Posts

Hello everyone,I need some help.

Use LISP to insert dynamic block,But display:error: bad argument type: lentityp nil.I do not know how it is.

 

Code is as follows:

;Modify the dynamic property values
(defun DynamicProps (ename propname value / obj prpL cla cll prp)
 (vl-load-com)
 (setq obj (if (= (type ename) 'VLA-OBJECT) ename (vlax-ename->vla-object ename)))
 (if vla-getdynamicblockproperties (setq prpL (vlax-invoke obj 'getdynamicblockproperties)))
 (setq return
   (if (setq prp (vl-remove-if-not (function (lambda(x)(= (vlax-get-property x 'PropertyName) propname))) prpL))
     (mapcar (function (lambda(v)
       (if (and (/= value nil)(vlax-property-available-p v 'Value)(/= (type value)'LIST))
         (progn (vlax-put-property v 'Value value)(vla-update obj))
       )
       (if (and (vlax-property-available-p v 'AllowedValues) (vlax-get v 'AllowedValues))
         (list (vlax-get v 'Value)(vlax-get v 'AllowedValues))
  (vlax-get v 'Value)
       )
     )) prp)
     (mapcar (function (lambda(v)(list (vla-get-propertyName v)(vlax-get v 'Value) v))) prpL)
   )
 )
 return
)
;===============================================================
;Get polyline vertex
(defun verpoytexs (ename / plist pp n) 
 (setq obj (vlax-ename->vla-object ename))
 (setq plist (vlax-safearray->list
 (vlax-variant-value
    (vla-get-coordinates obj))))
 (setq n 0)
 (repeat (/ (length plist) 2)
    (setq pp (append pp (list (list (nth n plist)(nth (1+ n) plist)))))
    (setq n (+ n 2))
 )
 pp
)
;===============================================================
(defun c:tt ( / ss pt_copy pl_pt_lst off_real)
 (princ  "\n Select the block to be processed:" )
 (setq ss (ssget ":S" '((0 . "insert"))))
 (setq pt_copy (cdr (assoc 10 (entget  (ssname ss 0)))))
 (or (= (vla-get-isdynamicblock (vlax-ename->vla-object e)):vlax-true) (exit))
 (princ  "\n Select polyline to be processed:" )
 (setq pl_pt_lst (verpoytexs  (ssname (ssget ":S" '((0 . "LWPOLYLINE"))) 0)))
 (setq off_real (getreal "\n Enter the interval width:"))
 (mapcar
       '(lambda (p1 p2)
          (vl-cmdf ".copy" ss "" "_none" pt_copy "_none" p1)
          (vl-cmdf ".rotate" (entlast) "" "_none" p1 "R" 0 p2)
          (DynamicProps (entlast) "L" (- (distance p1 p2) off_real))
        )
       pl_pt_lst
       (cdr pl_pt_lst)
     )
 (princ)
)
(vl-load-com)

Insert dynamic block.dwg

Link to comment
Share on other sites

(defun c:tt ( / ss pt_copy pl_pt_lst off_real)
 (princ  "\n Select the block to be processed:" )
[b]  (if (and
(setq ss (ssget ":S" '((0 . "insert"))))
(or (= (vla-get-isdynamicblock (vlax-ename->vla-object [color="blue"](setq e (ssname ss 0))[/color])):vlax-true) (exit))
(princ "\n Select polyline to be processed:")
(setq pl (ssget ":S" '((0 . "LWPOLYLINE"))))
(setq off_real (getreal "\n Enter the interval width:"))
     )[/b]
   (progn
  (setq pt_copy (cdr (assoc 10 (entget  [b][color="blue"]e[/color][/b]))))
  (setq pl_pt_lst (verpoytexs  (ssname [b]pl[/b] 0)))
  (mapcar
        '(lambda (p1 p2)
           (vl-cmdf ".copy" ss "" "_none" pt_copy "_none" p1)
           (vl-cmdf ".rotate" (entlast) "" "_none" p1 "R" 0 p2)
           (DynamicProps (entlast) "L" (- (distance p1 p2) off_real))
         )
        pl_pt_lst
        (cdr pl_pt_lst)
      )
   [b]  ); progn
   ); if[/b]
 (princ)
)

Edited by pBe
Link to comment
Share on other sites

(defun c:tt ( / ss pt_copy pl_pt_lst off_real)
 (princ  "\n Select the block to be processed:" )
[b]  (if (and
(setq ss (ssget ":S" '((0 . "insert"))))
(or (= (vla-get-isdynamicblock (vlax-ename->vla-object e)):vlax-true) (exit))
(princ "\n Select polyline to be processed:")
(setq pl (ssget ":S" '((0 . "LWPOLYLINE"))))
(setq off_real (getreal "\n Enter the interval width:"))
     )[/b]
   (progn
  (setq pt_copy (cdr (assoc 10 (entget  (setq e (ssname ss 0))))))
  (setq pl_pt_lst (verpoytexs  (ssname [b]pl[/b] 0)))
  (mapcar
        '(lambda (p1 p2)
           (vl-cmdf ".copy" ss "" "_none" pt_copy "_none" p1)
           (vl-cmdf ".rotate" (entlast) "" "_none" p1 "R" 0 p2)
           (DynamicProps (entlast) "L" (- (distance p1 p2) off_real))
         )
        pl_pt_lst
        (cdr pl_pt_lst)
      )
   [b]  ); progn
   ); if[/b]
 (princ)
)

 

Thank you for your help. But problem still exists.When select the block, interrupt and display "error: bad argument type: lentityp nil."

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...