Jump to content
pmadhwal7

Lisp automatic dimension

Recommended Posts

pmadhwal7

need a lisp to put align dimension refer attachment 

final output.JPG

input before.JPG

Share this post


Link to post
Share on other sites
BIGAL

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.

Share this post


Link to post
Share on other sites
Ish

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.

Share this post


Link to post
Share on other sites
pmadhwal7
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

Share this post


Link to post
Share on other sites
pmadhwal7
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

Share this post


Link to post
Share on other sites
BIGAL

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

Share this post


Link to post
Share on other sites
pmadhwal7
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

Share this post


Link to post
Share on other sites
myloveflyer
;;;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)

 

Share this post


Link to post
Share on other sites
BIGAL

Thanks myloveflyer.

 

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

Share this post


Link to post
Share on other sites
pmadhwal7
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

Share this post


Link to post
Share on other sites
pmadhwal7
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

 

 

Share this post


Link to post
Share on other sites
BIGAL

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.

Share this post


Link to post
Share on other sites
pmadhwal7
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

Share this post


Link to post
Share on other sites
BIGAL

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)

Share this post


Link to post
Share on other sites
pmadhwal7
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....

Share this post


Link to post
Share on other sites
Tharwat
Posted (edited)

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

Share this post


Link to post
Share on other sites
BIGAL

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

 

 

Share this post


Link to post
Share on other sites
pmadhwal7
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

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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