Author Topic: I need help with entnext  (Read 1676 times)

0 Members and 1 Guest are viewing this topic.

TAIKI

  • Guest
I need help with entnext
« on: May 16, 2015, 04:34:43 PM »
Hello

I want to move attribut name "alt"on block using ssget function to mark with a circle the insertion point of the block. So I don't understand how I can filter attribut.
Please can you help me?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test2a ( / e i s x )
  2.  
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4.     (if (setq s (ssget))
  5.         (repeat (setq i (sslength s))
  6.             (setq e (ssname s (setq i (1- i)))
  7.                   x (cdr (assoc 10 (entget e)))
  8.             )
  9.           (command "_.circle" x "0.02")
  10.        
  11.           (sssetfirst nil s)
  12.         )
  13.     )
  14. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  15. (setq en (ssname s 0))
  16. (while (/= "SEQEND" (cdr (assoc 0 (entget en))))
  17.   (setq en (entnext en)
  18.         tn (cdr (assoc -1 (entget en)))
  19.         p1 (cdr (assoc 10 (entget tn))))
  20.   )
  21.    (setq p2 (getpoint p1 "Spécifiez le deuxième point: "))
  22.         (vla-move (vlax-ename->vla-object tn)
  23.                   (vlax-3d-point p1)
  24.                   (vlax-3d-point p2)
  25.                   )
  26.  
  27. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  28.  
  29.     (princ)
  30. )

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: I need help with entnext
« Reply #1 on: May 17, 2015, 02:10:51 PM »
It is not completely clear to me what you want to do. But you cannot filter for a specific attribute with an ssget filter. But you can use ssget to filter for inserts with a given name and/or with attributes. But why don't you use nentsel to select the attribute?


TAIKI

  • Guest
Re: I need help with entnext
« Reply #2 on: May 17, 2015, 04:39:02 PM »
I'll explain much better, I want to move the attribut "alt" not another and on the same time place place a circle on the insertion point of the block containing the attribut.

I use ssget to place the circle, but for filter the attribut to move I don't know how to do.
With nentsel I can move attribut but I can't place the circle on insertion point of the block.

thanks for your help.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: I need help with entnext
« Reply #3 on: May 18, 2015, 04:00:04 AM »
Maybe these functions will help:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test_1 ( / enameAtt enameBlk)
  2.   (setq enameAtt (car (nentsel "\nSelect an attribute: "))) ; Ename of attribute reference.
  3.   (setq enameBlk (cdr (assoc 330 (entget enameAtt))))       ; Ename of block reference.
  4. )
  5.  
  6. (defun c:test_2 ( / attTag elistAtt elistBlk elistTmp enameAtt enameBlk enameTmp)
  7.   (setq attTag "ALT") ; Attribute tag in upper case.
  8.   (if
  9.     (and
  10.       (setq enameBlk (car (entsel "\nSelect an insert: "))) ; Ename of block reference.
  11.       (setq elistBlk (entget enameBlk))
  12.       (vl-position '(0 . "INSERT") elistBlk)
  13.       (vl-position '(66 . 1) elistBlk)
  14.     )
  15.     (progn
  16.       (setq enameTmp (entnext enameBlk))
  17.       (while
  18.         (and
  19.           (setq elistTmp (entget enameTmp))
  20.           (= (cdr (assoc 0 elistTmp)) "ATTRIB")
  21.           (/= (strcase (cdr (assoc 2 elistTmp))) attTag)
  22.         )
  23.         (setq enameTmp (entnext enameTmp))
  24.       )
  25.       ;; Now enameTmp is either an "ATTRIB" with the correct tag or a "SEQEND" entity.
  26.       (if (= (cdr (assoc 0 elistTmp)) "ATTRIB")
  27.         (progn
  28.           (setq enameAtt enameTmp) ; Ename of attribute reference.
  29.           (setq elistAtt elistTmp)
  30.         )
  31.       )
  32.     )
  33.   )
  34. )

Note: if you are tying to update attributes you should also consider the standard commands _ATTSYNC and _BATTMAN.
« Last Edit: May 18, 2015, 04:11:27 AM by roy_043 »

TAIKI

  • Guest
Re: I need help with entnext
« Reply #4 on: May 18, 2015, 03:03:08 PM »
Thanks Roy it work fine.
I doesn't know the 330 dxf code it's great idea.