Insert Lips drawed objects like a Block

Insert Lips drawed objects like a Block

Anonymous
Not applicable
1,224 Views
6 Replies
Message 1 of 7

Insert Lips drawed objects like a Block

Anonymous
Not applicable
Hello guys, I have an easy code for drawing a rectangle with the dimensions. I would like to insert it to a drawing file like an object, does somebody know how can I do this? Ther is the CODE:
0 Likes
Accepted solutions (1)
1,225 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

 

(defun c:Narez (/ X_Dist Y_Dist P0 P1 P2 P3 P4 P5 )
  (Setq	X_Dist (Getreal "\nX-Distance: ")
	Y_Dist (Getreal "\nY-Distance: ")
	P0     (Getpoint "\nInsertpoint: ")
	P1     (list (+ (car P0) X_Dist) (cadr P0))
	P2     (list (car P1) (+ (cadr P1) Y_Dist))
	P3     (list (car P0) (+ (cadr P0) Y_Dist))
  P4     (list (+ (car P0) 20) (+ (cadr P0) 20))
  P5     (list (+ (car P0) 10) (+ (cadr P0) 60))
  )
  (command "_rectang" P0 P2)
  (command "_TEXT" P4 40 0 X_Dist "")
  (command "_TEXT" P5 40 90 Y_Dist "")
  
  (princ)
)

 

0 Likes
Message 3 of 7

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:
... I have an easy code .... I would like to insert it to a drawing file like an object....

I don't quite understand what you're trying to do.  What is "it" that you want to insert in a drawing like an object?  The code itself?  Do you want to know how to load the code so you can use its defined command to draw rectangles with it?  Do you want what it draws to be combined into a Block?  Or something else?

 

[By the way, be sure to have running Object Snap turned off when you run it....]

Kent Cooper, AIA
0 Likes
Message 4 of 7

Anonymous
Not applicable

Hello, 

 

thank you for your reply. 

 

I want to combine it into a block when I draw it. 

 

Thank you.

0 Likes
Message 5 of 7

pbejse
Mentor
Mentor

As per order:

1 Lips inserted and drawed in an object like a block

lipsinsideblock.png

HTH

 

Message 6 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

.... I want to combine it into a block when I draw it. 


Try this:

 

(defun c:Narez (/ X_Dist Y_Dist P0 P1 P2 P3 P4 P5 ss)
  (Setq
    X_Dist (Getreal "\nX-Distance: ")
    Y_Dist (Getreal "\nY-Distance: ")
    P0 (Getpoint "\nInsertpoint: ")
    P1 (list (+ (car P0) X_Dist) (cadr P0))
    P2 (list (car P1) (+ (cadr P1) Y_Dist))
    P3 (list (car P0) (+ (cadr P0) Y_Dist))
    P4 (list (+ (car P0) 20) (+ (cadr P0) 20))
    P5 (list (+ (car P0) 10) (+ (cadr P0) 60))
  )
  (command "_rectang" P0 P2)
  (setq ss (ssadd (entlast))); start selection set with rectangle
  (command "_TEXT" "_non" P4 40 0 X_Dist)
  (ssadd (entlast) ss); add Text to selection set
  (command "_TEXT" "_non" P5 40 90 Y_Dist)
  (ssadd (entlast) ss); again
  (command
    "_.block" "YourBlockName" P0 ss "" ; removes from drawing, so:
    "_.insert" "YourBlockName" P0 "" "" ""
  ); command
  (princ)
)

 

I also removed the extraneous "" Enters at the ends of the Text commands, which caused trouble.

Kent Cooper, AIA
Message 7 of 7

Anonymous
Not applicable

It works well, thank you very mutch 🙂 

0 Likes