Jump to content

Recommended Posts

Posted

Hi all,

 

 

I have to dimension hundreds of stands (drawn as a closed polylines) on a floor plan.

I have found lisps that dimension all side of the 'stands' the problem is I don't need the internal dimensions so currently I am using 4 lisps.. select all left hand stands lisp adds left dims, bottom stands lisp adds bottom dim ETC.

 

 

 

 

Can any one help stop me going grey by writing a code that only dimensions the outside and doesn't dimension the internal ones (where the polylines overlap).

I think the attached pic describes it better.

fingers crossed!

help.jpg

  • Replies 38
  • Created
  • Last Reply

Top Posters In This Topic

  • gadgetjay

    16

  • BIGAL

    6

  • ronjonp

    6

  • hanhphuc

    4

Top Posters In This Topic

Posted Images

Posted

Getting all points then remove internal points.

 

 

Then need a clock sort routine so points are in a list. Then do dim pt1 pt2 etc.

Posted
Getting all points then remove internal points.

 

Then need a clock sort routine so points are in a list. Then do dim pt1 pt2 etc.

 

if floor plan is squared convex hull IMO is doable.

 

my suggestion (if squared plan) boundingbox offset inner say 1% ssget crossing erase internal dimensions easier?

Posted

hanhphuc good idea. Hit it with a hammer rather than spend hours trying to work it out. Now for some time.

Posted

Hi, sorry been dimensioning more stands!

I wish the venue was square - no such luck.

I've attached a drawing of just the stand outlines so you can see my pain..

Basic stand outline.dwg

Posted (edited)
Hi, sorry been dimensioning more stands!

I wish the venue was square - no such luck.

I've attached a drawing of just the stand outlines so you can see my pain..

 

Here is a good start based off your example drawing.

 

(defun c:foo (/ lm:makereadable _colinear a b d out p pp s th)
 ;; RJP 05.03.2018
 ;; Labels exterior edges of 'stands' with edge length
 (defun _colinear (p1 p2 p3 f) (equal (+ (distance p1 p2) (distance p2 p3)) (distance p1 p3) f))
 ;; Make Readable  -  Lee Mac
 ;; Returns a given angle corrected for text readability
 (defun lm:makereadable (a)
   ((lambda (a)
      (if (and (< (* pi 0.5) a) (<= a (* pi 1.5)))
 (+ a pi)
 a
      )
    )
     (rem (+ a pi pi) (+ pi pi))
   )
 )
 (cond
   ((setq s (ssget '((0 . "lwpolyline") (8 . "BoothOutline"))))
    (setq th 500)
    (foreach pl (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (setq p (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget pl))))
      (setq p
      (mapcar '(lambda (a b)
		 (list (polar a (angle a b) (* 0.5 (setq d (distance a b)))) a b (angle a b) d)
	       )
	      p
	      (append (cdr p) (list (car p)))
      )
      )
      (setq out (cons p out))
    )
    (foreach pt (setq out (apply 'append out))
      (and
 (null (vl-remove-if-not
	 '(lambda (x)
	    (or (equal (car pt) (car x) 1e-1) (_colinear (cadr x) (car pt) (caddr x) 1e-1))
	  )
	 (vl-remove pt out)
       )
 )
 (setq pp (polar (car pt) (- (cadddr pt) (/ pi 2.)) th))
 (entmakex (list '(0 . "TEXT")
		 '(100 . "AcDbEntity")
		 '(8 . "BoothOutlineLength")
		 '(100 . "AcDbText")
		 (cons 10 pp)
		 (cons 40 th)
		 '(62 . 1)
		 (cons 1 (rtos (/ (last pt) 1000.) 2 0))
		 (cons 50 (lm:makereadable (cadddr pt)))
		 '(72 . 1)
		 (cons 11 pp)
		 '(100 . "AcDbText")
		 '(73 . 2)
	   )
 )
      )
    )
   )
 )
 (princ)
)
(vl-load-com)

open?id=1iyVz-RxVVCLFjBcaVA-X_1lZUbSqGBuw

Edited by ronjonp
Posted (edited)

Ronjonp great job picked 565 and did in one go, probably best to pick small amounts at a time.

 

One suggestion for gadgetjay is use UCS OB plan pick objects on angle this makes square picking so much easier. Then UCS W Plan to go back.

Edited by BIGAL
Posted
Ronjonp posted earlier but "500 errors " great job picked 565 and did in one go, probably best to pick small amounts at a time.

 

One suggestion for gadgetjay is use UCS OB plan pick objects on angle this makes square picking so much easier. Then UCS W Plan to go back.

 

It was a quick example. Do you have anything to contribute with less than"500 errors" ? If you really look at the op example drawing it's less than ideal for an all in one solution.

Posted
It was a quick example. Do you have anything to contribute with less than"500 errors" ? If you really look at the op example drawing it's less than ideal for an all in one solution.

 

Thanks for this Ronjon - seems to be doing what i ask for...

i'm unsure what the 500 errors are i just hope its not wrong dimensions!

Posted
Thanks for this Ronjon - seems to be doing what i ask for...

i'm unsure what the 500 errors are i just hope its not wrong dimensions!

 

Ah Man - it was wrong dims...

Posted

Sorry guys the website kept giving me and others "Error 500" has occured.

Posted (edited)

ok so if i change

(cons 1 (rtos (/ (last pt) 1000.) 2 2))

 

i get the decimal places which corrects the errors in dimensions (phew)

 

is there a way to make the text offest 500 from the stand? - i tried justify text and 50% are inside 50% outside

Edited by gadgetjay
Posted (edited)
Here is a good start based off your example drawing.

 

(defun c:foo (/ lm:makereadable _colinear a b d out p pp s th)
 ;; RJP 05.03.2018
 ;; Labels exterior edges of 'stands' with edge length

 

indeed a good start! :thumbsup:

IMO the idea / algorithm is worth more than coding.

simple, short & faster than region boolean acUnion which need rounding tolerance

 

 

is there a way to make the text offest 500 from the stand? - i tried justify text and 50% are inside 50% outside

 

hi to be outside 100% the best solution is to involve or to learn coding ! :)

Ronjonp has done 90% of your tasks

 

my $0.02, In red to be tested

(defun [b][color="blue"]outline_TX[/color][/b] (p1 p2 h [color="red"][b][u]cw[/u][/b][/color] / pl d ro)
;hanhphuc 
 (setq pl (mapcar ''((x) (list (car x) (cadr x))) (list p1 p2)))
 (mapcar ''((a b) (set a (apply b pl))) '(ro d) '(angle distance))
 (entmakex
   (mapcar 'cons
    '(0 100 100 1 10 40 50 8 71 72)
    (list "MTEXT"
	  "AcDbEntity"
	  "AcDbMText"
[color="red"]		  (if (or [b][u]cw[/u][/b](< (* pi 0.5) ro (* pi 1.5)) )
	    (strcat (rtos d 2) "\\P ")
	    (strcat "\\P " (rtos d 2))
	    )[/color]
	  (apply 'mapcar (cons ''((a b) (/ (+ a b) 2.)) pl )
	  (if (zerop h)
	    (/ d[color="red"] 10.[/color])
	    h
	    )
	  ([color="red"]LM:[/color]MakeReadable ro)
	  "OUT"
	  5
	  5
	  )
    )
   )
 (princ)
 )

Edited by hanhphuc
added new argument CW
Posted

Hi hanhphuc,

 

 

Trying to learn the coding but something like this is beyond my reach - it helps when there are notes in the code so you know what's happening.

 

 

 

 

wasn't sure if you meant to place your code in Ronjonp's as a 'standalone' it errors malformed list?

Posted
Hi hanhphuc,

 

 

Trying to learn the coding but something like this is beyond my reach - it helps when there are notes in the code so you know what's happening.

 

 

wasn't sure if you meant to place your code in Ronjonp's as a 'standalone' it errors malformed list?

 

Good to hear you are learning :thumbsup:

you are right this is not simple.

you can't simply add in the code, causing malformed list - missing parentheses or bracket ( ) or extra bracket ! to debug , command VLIDE or VLISP to open the editor

 

a sub-function needs to supply arguments.

i modified previous post#13 outline_TX function with additional argument cw. please re-copy

quick & dirty test

you try to draw 2 rectangles ccw & cw to test..

(defun c:test (/ s v ov l)
 (setq	v  '(angdir angbase)
ov (mapcar 'getvar v)
)
 (mapcar 'setvar v (list 1 (/ pi 2.)))
 (while (setq s (ssget "_:S:E+." '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1))))
   (setq l (mapcar 'cdr (vl-remove-if ''((x) (/= (car x) 10)) (entget (ssname s 0)))))
   (mapcar ''((a b) ([color="blue"][b]outline_TX[/b][/color] a b 0. [color="red"](LM:ListClockwise-p l)[/color]))
    l
    (append (cdr l) (list (car l)))
    )
   )
 (mapcar 'setvar v ov)
 (princ)
 )


     ;; List Clockwise-p - Lee Mac
     ;; Returns T if the point list is clockwise oriented
     (defun LM:ListClockwise-p ( lst )
       (minusp
         (apply '+
           (mapcar
             (function
               (lambda ( a b )
                 (- (* (car b) (cadr a)) (* (car a) (cadr b)))
               )
             )
             lst (cons (last lst) lst)
           )
         )
       )
     )

Posted

Thanks hanhphuc I appreciate the help but feel I drowning!

 

 

I found if I add to Ronjonp's Code

(setvar 'luprec 2)

it places the text outside - is there a problem doing it this way?

 

 

 
(defun c:foo (/ lm:makereadable _colinear a b d out p pp s th)
 ;; RJP 05.03.2018

 ;; Labels exterior edges of 'stands' with edge length
 (defun _colinear (p1 p2 p3 f) (equal (+ (distance p1 p2) (distance p2 p3)) (distance p1 p3) f))

 ;; Make Readable  -  Lee Mac
 ;; Returns a given angle corrected for text readability
 (defun lm:makereadable (a)
   ((lambda (a)
      (if (and (< (* pi 0.5) a) (<= a (* pi 1.5)))
 (+ a pi)
 a
      )
    )
     (rem (+ a pi pi) (+ pi pi))
   )
 )
 (cond
   ((setq s (ssget '((0 . "lwpolyline") (8 . "BoothOutline"))))
    (setq th 500)
    (foreach pl (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (setq p (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget pl))))
      (setq p
      (mapcar '(lambda (a b)
   (list (polar a (angle a b) (* 0.5 (setq d (distance a b)))) a b (angle a b) d)
        )
       p
       (append (cdr p) (list (car p)))
      )
      )
      (setq out (cons p out))
    )
    (foreach pt (setq out (apply 'append out))
      (and
 (null (vl-remove-if-not
  '(lambda (x)
     (or (equal (car pt) (car x) 1e-1) (_colinear (cadr x) (car pt) (caddr x) 1e-1))
   )
  (vl-remove pt out)
       )
 )

 (setq pp (polar (car pt) (- (cadddr pt) (/ pi 2.)) th))

(setvar 'luprec 2)
 (entmakex (list '(0 . "TEXT")
   '(100 . "AcDbEntity")
   '(8 . "BoothDim")
   '(100 . "AcDbText")
   (cons 10 pp)
   (cons 40 th)
   '(62 . 1)
   (cons 1 (rtos (/ (last pt) 1000.) 2 2))
   (cons 50 (lm:makereadable (cadddr pt)))
   '(72 . 1)
   (cons 11 pp)
   '(100 . "AcDbText")
   '(73 . 2)
    )
 )

      )
    )
   )
 )
 (princ)
)
(vl-load-com)


Posted

Here's an old routine that should work with a Heavy (not LWpolyline ) Closed PLine outer border -David

DIM-CPL.LSP

Posted
Thanks hanhphuc I appreciate the help but feel I drowning!

I found if I add to Ronjonp's Code

(setvar 'luprec 2)

it places the text outside - is there a problem doing it this way?

linear units precision 2,similar (rtos x 2 2)

nothing to do with placement

 

To suit your drawing, try to modify/add in the code post#13 (in red)

  

(defun [color="blue"]OUTLINE_TX[/color] (p1 p2 h cw  / pl d ro)
 (setq pl (mapcar '(lambda(x) (list (car x) (cadr x))) (list p1 p2)))
 (mapcar '(lambda(a b) (set a (apply b pl))) '(ro d) '(angle distance))
 [color="red"](setq d (* d 0.001))[/color]
 (entmakex 
.....
  	..... 

 

sorry about the 500 internal server error very painful to reply post

 

iMO it's diffucult for you as newbie,

nvm i try my best to assist, example in Ronjop's code just replace this part

 (setq pp (polar (car pt) (- (cadddr pt) (/ pi 2.)) th))
 (entmakex (list '(0 . "TEXT")
		 '(100 . "AcDbEntity")
		 '(8 . "BoothOutlineLength")
		 '(100 . "AcDbText")
		 (cons 10 pp)
		 (cons 40 th)
		 '(62 . 1)
		 (cons 1 (rtos (/ (last pt) 1000.) 2 0))
		 (cons 50 (lm:makereadable (cadddr pt)))
		 '(72 . 1)
		 (cons 11 pp)
		 '(100 . "AcDbText")
		 '(73 . 2)
	   )
 )

 

to this.

 

[color="green"] ;; modified by hanhphuc [/color]
       ([color="blue"]OUTLINE_TX[/color] (cadr pt) (caddr pt) 500 (LM:ListClockwise-p (apply 'append (mapcar ''((x)(list (cadr x)(caddr x))) out ))))

 

It's simple right? ( OUTLINE_TX FromStartPoint ToEndPoint Text_Height ClockWise_Predicate )

; with 4 arguments. in blue is the function symbol & in deep purple is argument

as you can see i also used Lee Mac's function LM:ListClockwise-p

Posted (edited)
Ah Man - it was wrong dims...

 

Really? With the example drawing you gave it appeared to be working correctly. Be aware that this code only looks at straight edges. If you have an edge with a bulge, it will return an incorrect length.

Edited by ronjonp
Posted

it was a decimal error as some of the stands had .5s - no biggy!

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