Jump to content

Dividing area to a number of sub areas


Begde

Recommended Posts

Dear all,

I'm seeking help in this one also. I'm looking for a routine that will divide an area to selected sub areas and drawing the boundaries of new areas inside the parent area.

thanks in advance

Link to comment
Share on other sites

Just a quick shot on this way with no error checking

 
(defun C:A2S(/ ang1 ang2 len osm p1 p2 p3 p4 wid)
    (command "_undo" "_be")
 (setq osm (getvar "osmode"))
  (setvar "cmdecho" 0)
(if
 (and
      (setq p1 (getpoint "\nLower  Left corner point: "))
   (setq p3 (getpoint p1 "\nUpper  Right corner point: "))
 (setq p2 (getpoint p3 "\nLower  Right corner point: ")))
 (progn
 (setq ang1 (angle p2 p1) len (distance p1 p2))
 (setq p2 (polar p2 ang1 (/ len 2)))  
 (setq p4 (polar p3 ang1 len))
 (setq ang2 (angle p1 p4) wid  (distance p1 p4))
 (setq p3 (polar p2 ang2 wid))
 (command "_pline"  "_non" p1  "_non"p2  "_non"p3  "_non"p4 "_CL")
 (command "_copy" (entlast) "" "_non"p1 "_non"p2)
)
 )
 (setvar "osmode" osm)
 (command "_undo" "_e")
 (princ)
 )

  • Like 1
Link to comment
Share on other sites

Well, try this one instead

 
(defun C:A2S(/ ang1 ang2 len osm p1 p2 p3 p4 wid);;OK
   (setq *num* 2)
 (command "_undo" "_be")
 (setq osm (getvar "osmode"))
  (setvar "cmdecho" 0)
(if
 (and
      (setq p1 (getpoint "\nLower  Left corner point: "))
   (setq p3 (getpoint p1 "\nUpper  Right corner point: "))
 (setq p2 (getpoint p3 "\nLower  Right corner point: "))
   (setq num (cond
         ((getint (strcat"\nSpecify number of subareas (Hit to accept) <"(itoa *num*)">: ")))
         (num)))
         )
 (progn
   (setq *num* num)
 (setq ang1 (angle p1 p2)
ang2 (angle p2 p3)
len (distance p1 p2)
wid  (distance p2 p3)
)
 (setq p2 (polar p1 ang1 (/ len num)))  ;;number of divisions were added
 (setq p4 (polar p1 ang2 wid))
 (setq p3 (polar p2 ang2 wid))
 (command "_pline"  "_non" p1  "_non"p2  "_non"p3  "_non"p4 "_CL")

 (repeat (- num 1)(command "_copy" (entlast) "" "_non" p1 "_non" p2)
   (setq p1 p2
  p2 (polar p1 ang1 (/ len num))))
)
 )
 (setvar "osmode" osm)
 (command "._undo" "_e")
 (princ)
 )

  • Like 1
Link to comment
Share on other sites

  • 4 months later...
  • 2 years later...
Dear all,

I'm seeking help in this one also. I'm looking for a routine that will divide an area to selected sub areas and drawing the boundaries of new areas inside the parent area.

thanks in advance

 

Probably this

Link to comment
Share on other sites

  • 8 years later...
On 2/11/2013 at 5:11 PM, fixo said:

Juste un coup rapide sur cette façon sans vérification d’erreur

 

 
(defun C:A2S(/ ang1 ang2 len osm p1 p2 p3 p4 wid)
    (command "_undo" "_be")
 (setq osm (getvar "osmode"))
  (setvar "cmdecho" 0)
(if
 (and
      (setq p1 (getpoint "\nLower  Left corner point: "))
   (setq p3 (getpoint p1 "\nUpper  Right corner point: "))
 (setq p2 (getpoint p3 "\nLower  Right corner point: ")))
 (progn
 (setq ang1 (angle p2 p1) len (distance p1 p2))
 (setq p2 (polar p2 ang1 (/ len 2)))  
 (setq p4 (polar p3 ang1 len))
 (setq ang2 (angle p1 p4) wid  (distance p1 p4))
 (setq p3 (polar p2 ang2 wid))
 (command "_pline"  "_non" p1  "_non"p2  "_non"p3  "_non"p4 "_CL")
 (command "_copy" (entlast) "" "_non"p1 "_non"p2)
)
 )
 (setvar "osmode" osm)
 (command "_undo" "_e")
 (princ)
 )
 

 

VERRY GOOD THANKS

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