Jump to content

IDEA TO determinatING Location LENGTHS FOR POLYLINE


Recommended Posts

Posted (edited)
Hello all.....
Sorry for my language
Is there a 
IDEA TO determinatING Location LENGTHS FOR POLYLINE
I try depending on the starting and ending coordinates
And then from the center POLYLINE
If possible, someone has an idea
To share the work
Photo attachment + working file
Thank you very much, everyone

 

A1.PNG

A2.PNG

QQ.dwg

Edited by CADTutor
Reduced text size
Posted

I cannot open your drawing, can you save as AutoCAD version 2010 or earlier

  • Like 1
  • Thanks 1
Posted

dlanorh a simple closed pline but it has arcs and wants line lengths based on angle in a quadrant 

 

image.thumb.png.c6d638320b31e99aab96a74a52bab406.png

Maybe start with lee-mac's pline details lisp, will have to have a think. Note pline will have to be checked for clockwise etc.

  • Thanks 1
Posted

It's the North/South/West/East bit that's confusing. The number of entries doesn't add up unless you get to see the drawing

  • Thanks 1
Posted (edited)

I want  determine location for all lengths

If it is located in the north with respect to the center of the area
Or some of them are in the East, West or South
Is it possible if we create a square around the area and drop the lengths on it to determine its position relative to the area
It is an idea, not a solution
I would like everyone to share his beautiful ideas if you find enough time

image.png

Edited by CADTutor
Reduced text size
Posted

You can determine North, South, East and West from the azimuth (not the angle) of the line segment, you just have to define what constitutes North South East and West. I would suggest anything lying between

 

45 degrees and 135 degrees would be East

135 degrees and 225 degrees would be South

225 degrees and 315 degrees would be West

anything else would be North

 

You'll need to get your >=, >, <= and < correct though

  • Thanks 1
Posted (edited)

hosneyalaa asks for example code in 1st post ? Some ideas 4 text strings depending on quad use strcat lengths then write a simple mtext 4 lines. I need some time. 

Something wrong where angles are exact like 0.0 not sure what I have done wrong.

(defun c:nsew ( / t1 t2 t3 t4 ss plent co-ord x pt1 pt2)
(setq t1 "Northing ")
(setq t2 "Easting ")
(setq t3 "Southing ")
(setq t4 "Westing ")
(setq ss (ssget "+.:E:S" '((0 . "LWPOLYLINE"))))
(setq plent (ssname ss 0))
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget plent))))
(setq co-ord (cons (nth (- (length co-ord) 1) co-ord)co-ord))
(setq x 0)
(setq pt1 (nth x co-ord))
(repeat (- (length co-ord) 1)
(setq pt2 (nth (setq x (+ x 1)) co-ord))
(setq ang (angle pt1 pt2))
(setq dist (strcat (rtos (distance pt1 pt2) 2 3) "  "))
(cond
((equal ang 0.0 1e-05 )(setq t1 (strcat t1 dist " " (rtos ang 2 3))))
((and (>= ang 0.00000001 )(<= ang (/ pi 2.0)))(setq t1 (strcat t1 dist " " (rtos ang 2 3))))
((and (> ang (+ (/ pi 2.0) 0.00000001))(<= ang pi))(setq t2 (strcat t2 dist " " (rtos ang 2 3))))
((and (> ang (+ pi 0.00000001))(<= ang (* 1.5 pi)))(setq t3 (strcat t3 dist " " (rtos ang 2 3))))
((and (> ang (+ (* 1.5 pi) 0.00000001))(<= ang (* 2.0 pi)))(setq t4 (strcat t4 dist " " (rtos ang 2 3))))
((alert (strcat "missed " (rtos ang 2 6))))
)
(setq pt1 pt2)
)
(setq pt1 (getpoint "\nPick Top left for text"))
(setq pt2 (getpoint pt1 "\nPick Bottom right"))
(command "mtext" pt1 pt2 t1 t2 t3 t4 "")
(princ)
)
(c:nsew)

 

Edited by BIGAL
  • Thanks 1
Posted (edited)
thank you 

dlanorh   BIGAL

To respond and interact with me
And already by the idea of the corners before  dlanorh
And the wonderful code before  BIGAL
This is what I was asking
Thank you very much
Always be well and
good health
Edited by CADTutor
Reduced text size
Posted

dlanorh I was having problem with angle 0.0 draw a rectang, (> azi 0.0) what about 0.0 in cond,  good idea using vlax-curve.

 

;simple clock wise test by Gile

(defun gc:clockwise-p ( p1 p2 p3 ) (< (sin (- (angle p1 p3) (angle p1 p2))) -1e-14))

 

  • Thanks 1
Posted
2 hours ago, BIGAL said:

dlanorh I was having problem with angle 0.0 draw a rectang, (> azi 0.0) what about 0.0 in cond,  good idea using vlax-curve.

 


;simple clock wise test by Gile

(defun gc:clockwise-p ( p1 p2 p3 ) (< (sin (- (angle p1 p3) (angle p1 p2))) -1e-14))

 

 

I use Gile's code alot, but prefer to use the offset method for closed polylines, as you can construct a ccw polygon where the first half reports as clockwise (crescent shape). I just haven't had a chance to update the other parts of the routine where the azimuths will fill the opposite string.

  • Thanks 1
Posted (edited)
On 23/03/2020 at 22:56, dlanorh said:

@hosneyalaa Attached is attempt so far. This only works for clockwise polylines at present but I should be able to incorporate ccw polylines tomorrow.

 

Hope this is what you're after.

 

 

Bearing_and_DistancePolyH.lsp 3.95 kB · 3 downloads

 

dlanorh 

Thank you very much
Interesting code
Thank you for help

 

Edited by CADTutor
Reduced text size
Posted
2 hours ago, sanju2323 said:

@dlanorh I have tested this lisp on another drawing but it mixes some length in different directions.

Plot Length.dwg 172.89 kB · 1 download

 

I am aware that there are many shapes where it will be deemed wrong, but it is subjective. See attached drawing. If you rotate the left most shape so that "West" is vertical it will give the correct answer.

 

There is no correct answer when a segment is visible from multiple quadrants. This is a just a simple algorithm  that sorts segments according to the azimuth of that segment (or the chord if the segment is arc'd). I'm sure there is a better algorithm, but Rome wasn't built in a day. I'll cogitate on a minimum enclosing boundingbox.

 

Plot Length comments.dwg

Posted

Don't understand this "There is no correct answer when a segment is visible from multiple quadrants." if you walk around any pline shape say clockwise the angle forward will change between the two vertices making that segment so it can only exist in one quadrant. It can fall on 0.0 90 etc.

 

(defun c:test ( / plent co-ord x ang)
(setq plent (entsel "\nPick pline"))
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))
(setq co-ord (cons (nth (- (length co-ord) 1) co-ord) co-ord))
(setq x 0)
(repeat (- (length co-ord) 1)
(setq ang (angle (nth x co-ord)(nth (setq x (+ x 1)) co-ord)))
(princ (strcat "\n" (rtos ang 2 4)))
)
)
(c:test)

image.thumb.png.24d18cd6243b4412a6520261dcde312e.png

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