Jump to content

Recommended Posts

Posted

I've searched around and can't find a complete answer for this. I want to simply insert a block to the endpoint the user picks. But I also want the block to change to the layer of the object where the user picked the endpoint. So I just want the user to have to pick the insertion point and from that point, get the layer of the object, and also use it as the block insertion point later in the LISP without the user having to pick it again. Here's what I have so far (without the beginning and end of LISP):

 

(setq cmdecho (getvar "cmdecho"))
   (setvar "CMDECHO" 0)
   (setq clayer (getvar "clayer"))
   (setq osmode (getvar "osmode"))
   (setvar "OSMODE" 1)
   (setq Pick (entsel "\nPick Point"))
   (if(null Pick)
       (command "clayer")
       (setvar "CLAYER" (cdr (assoc 8 (entget (car Pick)))))
   )
   (command "insert" "ISO-VTR" pause "" "" pause)
   (setvar "OSMODE" osmode)
   (setvar "CMDECHO" cmdecho)
   (setvar "CLAYER" clayer)

 

I know I'm not thinking about something simple, hopefully someone can shine light on it.

 

Thanks!

Posted

How about:

(if (setq Pick (entsel "\nPick Point"))
(command "insert" "ISO-VTR" pause "" "" pause
         "_CHPROP" (entlast) "" "_LA" (cdr (assoc 8 (entget (car Pick)))) "")
)

 

I will also change the selection prompter to something more relevant - you dont select a point there, but an entity.

 

Regards,

Mircea

Posted
:? this is still requiring 2 point selections, isn't it? I'd need the point picked (preferrably endpoint of a line selected by user) to also be put in where the first "pause" is after the block insert.
Posted

To use a point from the entity selected by user as insertion point for block should extract that information based on entity type; for line the endpoints are stored in DXF codes 10 and 11 (got with ENTGET); should compare the distances from those point to the selection point returned by ENTSEL to use which one is closer.

 

To use a point as argument for block insertion:

 

(command "insert" "ISO-VTR" (cadr Pick) "" "" pause)

 

Regards,

Mircea

Posted

Ah, Thank you much! I was trying it with (getpoint). :D

Posted

An example for lines:

 

(if (setq Pick (entsel "\nPick Point"))
(progn
 (setq listEnt  (entget (car Pick))
       selPoint (cadr Pick))
 (cond
  ((member '(0 . "LINE") listEnt)   ;;; line entity
   (if (< (distance (setq point1st (cdr (assoc 10 listEnt))) selPoint)
          (distance (setq point2nd (cdr (assoc 11 listEnt))) selPoint))
    (setq blockPoint point1st)
    (setq blockPoint point2nd)
   )
  )
  [color=blue]; extend for other entity types[/color]
 )

 (command "_INSERT" "ISO-VTR" blockPoint "" "" pause
          "_CHPROP" (entlast) "" "_LA" (cdr (assoc 8 (entget (car Pick)))) "")
)
)

Regards,

Mircea

Posted

Got it, I'll play around with it. Thanks again!

Posted

My pleasure, you're welcome!

 

Regards,

Mircea

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