Jump to content

Lisp automatic dimension


pmadhwal7

Recommended Posts

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • pmadhwal7

    14

  • BIGAL

    10

  • myloveflyer

    1

  • Ish

    1

Top Posters In This Topic

Posted Images

DRAW XLINE PERPENDICULAR THAN EXTRIM FROM BOTH SIDE GREEN AND CENTER LINE.

REMAIN PART OF XLINE, YOU CAN USE AUTOMATIC DIMENSION LISP AND SELECT ALL REMAIN PART OF XLINE. YOU WILL GET DIMENSION.

Link to comment
Share on other sites

On 8/4/2019 at 10:30 AM, Ish said:

DRAW XLINE PERPENDICULAR THAN EXTRIM FROM BOTH SIDE GREEN AND CENTER LINE.

REMAIN PART OF XLINE, YOU CAN USE AUTOMATIC DIMENSION LISP AND SELECT ALL REMAIN PART OF XLINE. YOU WILL GET DIMENSION.

the data i have not straight line it's road line

Link to comment
Share on other sites

On 8/4/2019 at 7:10 AM, BIGAL said:

Did you ask similar over at Autodesk forums ? I thought it was solved.

 

This is known as a Peg and shift report, take 2 alignments and compare.

no i didn't ask

Link to comment
Share on other sites

On 8/6/2019 at 4:21 PM, BIGAL said:

The answer is over at the Autodesk forum the alignment of the text, would require the code to be adjusted. 

NOT FOUND

Link to comment
Share on other sites

;;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/change-in-lisp-to-get-e-n-coordinates-added-to-ch/td-p/8933843
;;;Author dbhunia
(defun c:Chin (/ s p c a d tp sch)
(setvar "cmdecho" 0)
  (setq sch (getstring "\nSpecify start chainage : <0>"))			;"0" is set as the default value
  (if (= sch "")(setq sch "0"))
  (if
    (and (setq s (car (entsel "\nPick a polyline :")))
	 (or (= (cdr (assoc 0 (entget s))) "LWPOLYLINE")
	     (alert "Invalid object! Please pick a polyline only.")
	 )
    )
     (while
       (and
	 (setq
	   p (getpoint "\nSpecify point perpendicular to polyline :")
	 )
	 (setq c (vlax-curve-getclosestpointto s p))
	 (setq a (angle p c))
	 (not (grdraw p c 1 -1))
	 ;; rubber line in red colour.
	 (setq d (angle	'(0. 0. 0.)
			(vlax-curve-getfirstderiv
			  s
			  (vlax-curve-getparamatpoint s c)
			)
		 )
	 )
	 (or
	   (or (equal (rem (+ d (* pi 0.5)) (+ pi pi)) a 1e-4)
	       (equal (rem (+ d (* pi 1.5)) (+ pi pi)) a 1e-4)
	   )
	   (alert
	     "Picked point is not a perpendicular to picked polyline. <!>"
	   )
	 )
	 (setq tp (getpoint "\nSpecify Point for Text : "))
       )		 
		(command "_.QLEADER" p tp "" 1 
				(strcat "CH=" sch "+" (rtos (vlax-curve-getdistatpoint s c) 2 3))
				(strcat "E=" (rtos (car p) 2 3))
				(strcat "N=" (rtos (cadr p) 2 3))
				""
		)
		(vlax-put-property (vlax-ename->vla-object (entlast)) 'height 0.6);;; Text Height 0.6
     )
  )
  (setvar "cmdecho" 1)
  (princ)
)
(vl-load-com)

 

Link to comment
Share on other sites

1 hour ago, BIGAL said:

Thanks myloveflyer.

 

The automated version of this would do say all vertice points or at fixed chainages. Again peg and shift report.

fixed points like i attached the image

Link to comment
Share on other sites

3 hours ago, myloveflyer said:

;;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/change-in-lisp-to-get-e-n-coordinates-added-to-ch/td-p/8933843
;;;Author dbhunia
(defun c:Chin (/ s p c a d tp sch)
(setvar "cmdecho" 0)
  (setq sch (getstring "\nSpecify start chainage : <0>"))			;"0" is set as the default value
  (if (= sch "")(setq sch "0"))
  (if
    (and (setq s (car (entsel "\nPick a polyline :")))
	 (or (= (cdr (assoc 0 (entget s))) "LWPOLYLINE")
	     (alert "Invalid object! Please pick a polyline only.")
	 )
    )
     (while
       (and
	 (setq
	   p (getpoint "\nSpecify point perpendicular to polyline :")
	 )
	 (setq c (vlax-curve-getclosestpointto s p))
	 (setq a (angle p c))
	 (not (grdraw p c 1 -1))
	 ;; rubber line in red colour.
	 (setq d (angle	'(0. 0. 0.)
			(vlax-curve-getfirstderiv
			  s
			  (vlax-curve-getparamatpoint s c)
			)
		 )
	 )
	 (or
	   (or (equal (rem (+ d (* pi 0.5)) (+ pi pi)) a 1e-4)
	       (equal (rem (+ d (* pi 1.5)) (+ pi pi)) a 1e-4)
	   )
	   (alert
	     "Picked point is not a perpendicular to picked polyline. <!>"
	   )
	 )
	 (setq tp (getpoint "\nSpecify Point for Text : "))
       )		 
		(command "_.QLEADER" p tp "" 1 
				(strcat "CH=" sch "+" (rtos (vlax-curve-getdistatpoint s c) 2 3))
				(strcat "E=" (rtos (car p) 2 3))
				(strcat "N=" (rtos (cadr p) 2 3))
				""
		)
		(vlax-put-property (vlax-ename->vla-object (entlast)) 'height 0.6);;; Text Height 0.6
     )
  )
  (setvar "cmdecho" 1)
  (princ)
)
(vl-load-com)

 

din't needed like this check the below link for more

 

 

Link to comment
Share on other sites

You can use VL getclosestpointto so just pick all he Leaders ? get end point and compare to road pline. Just need to confirm it is a "leader" ? What layer for dims and style name.

Link to comment
Share on other sites

17 minutes ago, BIGAL said:

You can use VL getclosestpointto so just pick all he Leaders ? get end point and compare to road pline. Just need to confirm it is a "leader" ? What layer for dims and style name.

yes sir it's leader

Link to comment
Share on other sites

Have a look at this no error checking and you need to set current dimstyle 

 


; peg shift routine
; By AlanH Consulting Aug 2019 

(alert "pick leaders when asked for selection")

(defun c:pegshift ( / ss obj obj2 obj3 co-ords pt1 pt2)
(setq ss (ssget (list (cons 0 "leader"))))
(setq obj (vlax-ename->vla-object (car (entsel "Pick pline"))))
(repeat (setq x (sslength ss))
(setq obj2 (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(setq co-ords  (vlax-safearray->list
    (vlax-variant-value
      (vlax-get-property  obj2  "Coordinates"       )
    )
  )
)
(setq pt1 (list (nth 0 co-ords)(nth 1 co-ords)))
(setq pt2 (vlax-curve-getclosestpointto obj pt1))
(command "dim" "_al" pt1 pt2 pt1 "" "exit")
(setq obj3  (vlax-ename->vla-object (entlast)))
(vla-put-ExtLine2Suppress obj3 -1)
(vla-put-ExtLine1Suppress obj3 -1)
)
)
(c:pegshift)

Link to comment
Share on other sites

1 hour ago, BIGAL said:

Have a look at this no error checking and you need to set current dimstyle 

 

 


; peg shift routine
; By AlanH Consulting Aug 2019 

(alert "pick leaders when asked for selection")

(defun c:pegshift ( / ss obj obj2 obj3 co-ords pt1 pt2)
(setq ss (ssget (list (cons 0 "leader"))))
(setq obj (vlax-ename->vla-object (car (entsel "Pick pline"))))
(repeat (setq x (sslength ss))
(setq obj2 (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(setq co-ords  (vlax-safearray->list
    (vlax-variant-value
      (vlax-get-property  obj2  "Coordinates"       )
    )
  )
)
(setq pt1 (list (nth 0 co-ords)(nth 1 co-ords)))
(setq pt2 (vlax-curve-getclosestpointto obj pt1))
(command "dim" "_al" pt1 pt2 pt1 "" "exit")
(setq obj3  (vlax-ename->vla-object (entlast)))
(vla-put-ExtLine2Suppress obj3 -1)
(vla-put-ExtLine1Suppress obj3 -1)
)
)
(c:pegshift)

 

it was asking for select object when i am going to select polyline it was showing 0 object selected....

Link to comment
Share on other sites

Hi,

What is the type of the object in the attached image? Dimension or Leader or Mleader?

Can you upload sample drawing?

 

image.png.17d9c80f4f2ec191f25351e4bfcde553.png

Edited by Tharwat
Link to comment
Share on other sites

The leaders are picked by the selection just window/pick which ones, you need then to pick the road alignment pline. You must set correct dimstyle to use as well. 

 

change (entsel "Pick pline") To (entsel "Pick road pline")

 

image.thumb.png.8f01d9ff7d06f7dab0ffa20aa1a3fb43.png

 

 

Link to comment
Share on other sites

On 8/10/2019 at 4:10 PM, Tharwat said:

Hi,

What is the type of the object in the attached image? Dimension or Leader or Mleader?

Can you upload sample drawing?

 

image.png.17d9c80f4f2ec191f25351e4bfcde553.png

check the attachment

sample.dwg

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