Jump to content

Search for my PLINE in an XREF with lisp


Recommended Posts

Hi, i´m currently using this code to find a specific line on layer B-B-E--2 in my model and then placing it.


  (if (setq EI (ssget "_X"'((0 . "LWPOLYLINE") (8 . "B-B-E--2") (410 . "Model")))) ;EI 15
      (setq co (list (car co) (- (cadr co)6)))
      (setq ip1 (list (car ip1) (- (cadr ip1)6)))
      (setq ip2 (list (car ip2) (- (cadr ip2)6)))

      (setq lip1 (list (-(car co)5) (-(cadr co)1))) ;First insertionpoint PLINE
      (setq lip2 (list (+(car co)7) (-(cadr co)1))) ;Second insertionpoint PLINE
      (command "PLINE" lip1 "L" lip2 "") ;create and insert pline
      (command "CHPROP" "last" "" "LT" "ACAD_ISO02W100" "S" "0.3" "C" "T" "0,191,255" "") ;change props
      (command "-MTEXT" ip1 "H" "1.6" ip2 "Brandcellsgräns EI 15" "")


I want to use the same function to find the same PLINE on the same layer in any type of XREF placed in the model.


Is this possible?


I have read a lot of other treads but I can´t understand them...



Link to comment
Share on other sites

ssget doesn't work on nested entity's you have to step through each xref's entity's one by one. and add them to a list if that match.


This makes a copy of polylines you want and moves them outside the xref.

(defun C:XREFEnts (/ blk NextEnt EntLst Lst)
  (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    (if (eq (vla-get-isXref blk) :vlax-true)
        (setq blkname (cdr (assoc 2 (entget (vlax-vla-object->ename blk)))))      
        (setq NextEnt (tblobjname "BLOCK" blkname))
        (while (setq NextEnt (entnext NextEnt))
          (setq Ent (entget NextEnt))
          (if (and (wcmatch (cdr (assoc 0 Ent)) "LWPOLYLINE") (wcmatch (cdr (assoc 8 Ent)) (strcat blkname "|B-B-E--2")))
            (setq Lst (cons (cdr (assoc -1 Ent)) Lst))
  (command "_.ncopy" Lst "" "_non" '(0 0) "_non" '(0 0))






Edited by mhupp
  • Thanks 1
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.

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...