Jump to content

changing global width of a rectangle


Guest lesliematt

Recommended Posts

Guest lesliematt

I am working on another project, and i want a lisp that will change the global width of a rectangle that the user selects automatically to 0.0625. what is an easy way of doing this??

 

-M

Link to comment
Share on other sites

Here it goes .......

(defun c:DoIt (/ pt width height end)
 (setq pt (getpoint"\nSpecify start point:")
width 0.0625
height (getdist"\nSpecify Height of Rectangle:")
end (list (+ (car pt) width)
	  (+ (cadr pt) height))
)
 
 (vl-cmdf "_.rectangle" pt end )
 (princ)
)

 

Enjoy it .....

 

Regards

 

Tharwat

Link to comment
Share on other sites

Here it goes .......

(defun c:DoIt (/ pt width height end)
 (setq pt (getpoint"\nSpecify start point:")
   width 0.0625
   height (getdist"\nSpecify Height of Rectangle:")
   end (list (+ (car pt) width)
         (+ (cadr pt) height))
   )

 (vl-cmdf "_.rectangle" pt end )
 (princ)
)

 

Enjoy it .....

 

Regards

 

Tharwat

 

Read the request again

Link to comment
Share on other sites

so why don't you post your codes instead ...

 

Not meant to make you mad. He wanted to select it is all. I'm still a grasshopper

Link to comment
Share on other sites

Not meant to make you mad. He wanted to select it is all. I'm still a grasshopper

 

I did not get mad, we are just sharing ideas and informations.... :D

 

So no problem at all , And if you take a look at his second thread, you'll find out that was right.

 

Regards

 

Tharwat

Link to comment
Share on other sites

Guest lesliematt
I did not get mad, we are just sharing ideas and informations.... :D

 

So no problem at all , And if you take a look at his second thread, you'll find out that was right.

 

Regards

 

Tharwat

 

Thank you Tharwat, this is what im looking for. i added more detail to my other post. they are related to each other. i am trying different things, but am pretty shaky on the language. if you could add a few comments in your coding, it would help me understand what is happening. Thanks

 

M

Link to comment
Share on other sites

Thank you Tharwat, this is what im looking for. i added more detail to my other post. they are related to each other. i am trying different things, but am pretty shaky on the language. if you could add a few comments in your coding, it would help me understand what is happening. Thanks

 

M

 

Here it is .... friend.

(defun c:DoIt (/ pt width height end)
 (setq pt (getpoint"\nSpecify start point:")		;the start point location
width 0.0625					;width of your desired rectangle
height (getdist"\nSpecify Height of Rectangle:");height of rectangle
end (list (+ (car pt) width)			;the X coordinate for the oppsite point of the start one
	  (- (cadr pt) height))			;the Y coordinate for the oppsite point of the start one
)
 
 (vl-cmdf "_.rectangle" pt end )			;the command which will draw your desired rectangle
 (princ)			
)

 

Regards.

 

Tharwat

Link to comment
Share on other sites

Guest lesliematt
Here it is .... friend.

(defun c:DoIt (/ pt width height end)
 (setq pt (getpoint"\nSpecify start point:")        ;the start point location
   width 0.0625                    ;width of your desired rectangle
   height (getdist"\nSpecify Height of Rectangle:");height of rectangle
   end (list (+ (car pt) width)            ;the X coordinate for the oppsite point of the start one
         (- (cadr pt) height))            ;the Y coordinate for the oppsite point of the start one
   )

 (vl-cmdf "_.rectangle" pt end )            ;the command which will draw your desired rectangle
 (princ)            
)

 

Regards.

 

Tharwat

 

 

Thank you so much. its a 'teach a man to fish' sort of thing.

Link to comment
Share on other sites

I am working on another project, and i want a lisp that will change the global width of a rectangle that the user selects automatically to 0.0625. what is an easy way of doing this??

 

-M

 

Pline Width or Width of rectangle?

Link to comment
Share on other sites

Guest lesliematt
Pline Width or Width of rectangle?

 

pline width, check my other thread, it is linked to this one. i need all the help i can get.

 

'making a polyline box using lisp'

Link to comment
Share on other sites

Quick one:

 

(defun c:plWid ( / ss wd )
 (vl-load-com)
 ;; © Lee Mac 2010

 (if (and (setq ss (ssget "_:L" '((0 . "LWPOLYLINE"))))
          (setq wd (getdist "\nSpecify Width: ")))
   (
     (lambda ( i / e )
       (while (setq e (ssname ss (setq i (1+ i))))
         (vla-put-Constantwidth (vlax-ename->vla-object e) wd)
       )
     )
     -1
   )
 )
 (princ)
)

 

Or, Slightly more advanced:

 

(defun c:plWid ( / *error* doc undo ss )
 (vl-load-com)
 ;; © Lee Mac 2010

 (defun *error* ( msg )
   (and undo (vla-EndUndoMark doc))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ)
 )

 (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
 
 (if
   (and
     (ssget "_:L" '((0 . "LWPOLYLINE")))
     (setq *wid*
       (cond
         (
           (getdist
             (strcat "\nSpecify Width <"
               (rtos
                 (setq *wid*
                   (cond ( *wid* ) ( 1.0 ))
                 )
               )
               "> : "
             )
           )
         )
         ( *wid* )
       )
     )
   )
   (progn
     (setq undo (not (vla-StartUndoMark doc)))
     
     (vlax-for obj (setq ss (vla-get-ActiveSelectionSet doc))
       (vla-put-ConstantWidth obj *wid*)
     )
     (vla-delete ss)
     (setq undo (vla-EndUndoMark doc))
   )
 )
 
 (princ)
)

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