Jump to content

Split installments faster


JuniorNogueira

Recommended Posts

Hello everyone, I'm here one more time 😅😅

I use the .lsp below to "get around" buildings more quickly the same prompts the user for 3 points and the amount of "house" and splits in equal portions closed polygons with a text in the center or asks for points and divides of the clicked size.

My doubt is:

 

Is there any way to make my process faster?

 

How can I improve .lsp?

 

 

Vcn1.thumb.gif.8120e837f0b3d70bc3ed9e6d79b4d588.gif

 

;;;;Code @Moshe-A   link:https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general

(defun c:vcn (/ formatColor calc_text_angle ; local functions
		    p0 p1 p2 rows color clrValue edge ang i t0 t1 t2 t3 t4 savTextStyle points^)

 (defun formatColor (/ isBaseColor ;| local function |; value)
   
  (defun isBaseColor ()
   (vl-some
    '(lambda (clr name)
      (if (= clr color) name)
     )
    '(1 2 3 4 5 6 7)
    '("red" "yellow" "green" "cyan" "blue" "magenta" "white")
   )
  ); isBaseColor

  ; here start formatColor
  (if (and (> color 0) (< color 255))
   (if (setq value (isBaseColor))
    value
    (strcat "color" (itoa color))
   ); progn
   (prompt "\ninvalid color.")
  ); if
 ); formatColor

  
 (defun calc_text_angle (/ a0)
  (setq a0 (angle p0 p1))

  (if (and
        (>  a0 (/ pi 2.0))
	(<= a0 (* pi 1.5))
      )
   (+ a0 pi)
   a0 
  )
 ); calc_text_angle

  
 (defun SpecifyNumberParcels (/ calcAccuratePoint ;| local function |; savSnapMode savSnapang savOrthoMode p3)
   
  (defun calcAccuratePoint (/ a0 a1 a2)
   (setq a0 (angle p0 p3))
   (setq a1 (angle p0 p2))

   (if (> a0 a1)
    (setq a2 (- a0 a1))
    (setq a2 (- a1 a0))
   )

   (if (> a2 (* pi 1.5))
    (setq a2 (- (* pi 2) a2))
   )

   (polar p0 (angle p0 p2) (* (cos a2) (distance p0 p3)))
  ); trigEdge

   
  (initget "Points")
  (setq rows (getint "\nPoints/Number of Parcels (---): "))

  (if (eq rows "Points")
   (progn
    (setq savSnapMode  (getvar "snapmode"))
    (setq savSnapang   (getvar "snapang"))
    (setq savOrthoMode (getvar "orthomode"))
    (command "snapang" (angtos (angle p0 p2) 0))
    (setvar "orthomode" 1)
    
    (setq points^ '())
    (if (setq p3 (getpoint p0 "\nSpecify first point: "))
     (progn
      (setq points^ (append points^ (list (calcAccuratePoint))))
      (while (setq p3 (getpoint p0 "\nSpecify next point: "))
       (setq points^ (append points^ (list (calcAccuratePoint))))
      )

      (setq points^ (append points^ (list p2)))
     ); progn
    ); if
     
    (setvar  "orthomode" savOrthoMode)
    (command "snapang"   savSnapang)
    (setvar  "snapmode"  savSnapMode)
   ); progn
  ); if

  rows
 ); SpecifyNumberParcels


 (defun exeMain ()
  (command "._pline" t0 t1 t2 t3 "_close")
  (command "._chprop" "_si" (entlast) "_color" color "")
  (setq t4 (inters t0 t2 t1 t3))
  (command "._text" "_middle" t4 0.2 (angtos (calc_text_angle) 0) clrValue)
  (command "._chprop" "_si" (entlast) "_color" color "")
  (setq t0 t3 t1 t2)
 )
  
  
 ; here start c:parcels  
 (setvar "cmdecho" 0)
 (command "._undo" "_begin")
 (setvar "blipmode" 1) 
 
 (if (and
       (setq p0 (getpoint "\nSpecify Parcels base point: "))
       (setq p1 (getpoint p0 "\nSpecify Parcels width: "))
       (setq p2 (getpoint p0 "\nSpecify Parcels length: "))
       (setq color (getint "\nSpecify Color: "))
       (setq clrValue (formatColor))
       (setq rows (SpecifyNumberParcels))
     )
  (progn
   (setq savTextStyle (getvar "textstyle"))
   (if (tblsearch "style" "Annotative")
    (setvar "textstyle" "Annotative")
    (command "._style" "Annotative" "arial" 0 1 0 "n" "n")
   )

   (cond
    ((eq rows "Points")
     (setq t0 p0 t1 p1)
     (foreach t3 points^
      (setq t2 (polar t1 (angle p0 p2) (distance t0 t3)))
      (exeMain)       
     )
    ); case
    ( t
     (setq edge (/ (distance p0 p2) rows)
           ang (angle p0 p2)
           t0 p0
	   t1 p1
	   i 0)
   
     (repeat rows
      (setq i (1+ i))
      (setq t2 (polar p1 ang (* edge i)))
      (setq t3 (polar p0 ang (* edge i)))
      (exeMain)       
     ); repeat
    ); case
   ); cond

   (setvar "textstyle" savTextStyle)
  ); progn
 ); if

 (setvar "blipmode" 0)
 (command "._redraw")
 (command "._undo" "_end")
 (setvar "cmdecho" 0)
  
 (princ)
)

 

Link to comment
Share on other sites

It looks pretty fast already? I guess some of the command calls could be removed but not sure it's worth it.

Also .. if your parcels are all the same width, maybe some of the math could be done by dividing into the length?

  • Like 1
Link to comment
Share on other sites

Yes Yes...
However there is some possibility of executing the task faster, since I have several cities to "get around" and even using .lsp is still slow.

 

Any idea? Do I accept suggestion?

 

Link to comment
Share on other sites

IMO you still have to make the decision on what to outline and how many lots are within it .. you can try the dividing lot width, but not sure how much time it will really save.

  • Confused 1
Link to comment
Share on other sites

Your running exemain repeatedly I think to make the plines, a simpler way may be use ucs set to 1st two points then array the pline lot, switch ucs back to world. One command not repeats.

 

Setting the ucs orientates the array to the angle.

Edited by BIGAL
  • Like 1
Link to comment
Share on other sites

I think what Bigal is talking about is setting your snapang and ortho (F8) to match a group of houses then you can easily draw consistent boundaries around a bunch of lots that have the same orientation.

Edited by ronjonp
  • Like 1
Link to comment
Share on other sites

Using the UCS and array would draw perp rectangs and as many as required. Need to find a few minutes and do code. Because the lots are different sizes there is no quick choice rather a few shortcuts.

Edited by BIGAL
  • Like 1
Link to comment
Share on other sites

Try this


; draw multi plinas as rectangs from 3 points
; By Alan H March 2019

(defun c:test ( / pt1 pt2 pt3 pt4 num dist1 dist2 ang oldang )
(setq oldang (getvar 'snapang))
(setq oldsnap (getvar 'osmode))
(setq pt1 (getpoint "Pick point 1"))
(setq pt2 (getpoint pt1 "Pick point 2"))
(setvar 'snapang (angle pt1 pt2))
(command "ortho" "on")
(setq pt3 (getpoint pt2 "Pick point 3"))
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(if (= ahdef nil)(setq ahdef 5))
(setq ahdef  (atof (nth 0(AH:getvalsm (list "Multi rectangs" "Howmany" 5 4 (rtos ahdef 2 0))))))
(setq num  ahdef)
(setq dist1 (/(distance pt1 pt2) num))
(setq dist2 (distance pt3 pt2))
(setq ang1 (angle pt1 pt2))
(setq ang2 (angle pt2 pt3))
(setq pt2 (polar pt1 ang1 dist1))
(setq pt3 (polar pt2 ang2 dist2))
(setq pt4 (polar pt3 (+ pi ang1) dist1))
(setvar 'snapang 0)
(setvar 'osmode 0)
(command "pline" pt1 pt2 pt3 pt4 "c")
(command "UCS" 3 pt1 pt2 pt3)
(command "-array" (entlast) "" "R" 1 num dist1)
(command "ucs" "w")
(setvar 'osmode oldsnap)
)
(c:test)

Multi GETVALS.lsp

Edited by BIGAL
Link to comment
Share on other sites

You were talking speed is array faster ?

 

Just an observation having spent years using what your after we just get the land title info then all lots done rubbermapped etc I was lucky worked for a government department so had real time access . Is there a reason you can not get that data, yes it may cost. But may be cheaper compred to time involved.

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