Jump to content

Is there a lisp file that can allow users to select dimensions then adjusts them after selection?


Recommended Posts

Posted (edited)

I am currently looking for that code where a user can select dimension lines (either plates with only one first dimension or with 2 dimensions) and upon "enter" would automatically set all the dimension lines to the following:

 

            Note: Annotation scale is 1:10

  • 1st dimension by 200mm from the object [those with yellow arrows]
  • 2nd dimension (if there are any) by 100mm from the 1st dimension [those with green arrows]

 

pmod.png.0350a8032f63bc8fd32983954f60ee1c.png

 

Edited by AeJay
Posted (edited)

Why not just add dims with the correct offsets, just have a a lisp that is preset say enter command  "dim200" so second dim is at 300. The lisp would ask for the 2 points and a direction all done. Could have many dims in the one lisp Dim100, dim250 etc. Even down to dim250-10.

 

I do have a way of pulling apart "unknown command" so could type any Dxxx and it would work. Currently have fillet, circles and offsets, C123 draws a circle with rad 123, can be any number for radius.

 

Still much easier D200 how many combos do you want ? Re offset values.

Edited by BIGAL
Posted
11 minutes ago, BIGAL said:

Why not just add dims with the correct offsets, just have a a lisp that is preset say enter command  "dim200" so second dim is at 300. The lisp would ask for the 2 points and a direction all done. Could have many dims in the one lisp Dim100, dim250 etc. Even down to dim250-10.

 

I do have a way of pulling apart "unknown command" so could type any Dxxx and it would work. Currently have fillet, circles and offsets, C123 draws a circle with rad 123, can be any number for radius.

 

Still much easier D200 how many combos do you want ? Re offset values.

I only need to offset by 200 and 300. Only 2 dimensions.

Posted (edited)

I noticed you have been trying to have a go so some hints

 

(defun c:d200

Get pt1 pt2 the dim points ask for a 3rd point for direction in or out. Near to pt1.

You can use the angle pt1 pt2 to work out  2 new offset points say from pt1 at 90 angle to the points, the closest distance to the pt3 is the one to use. ie the new pt4

Use (command "dim" "align"  pt1 pt2 pt4 "" "exit")

Just redo pt4 again for second dim (command "dim" "align"  pt1 pt2 pt4 "" "exit")

 

Have  ago we are here to help.

 

 

Edited by BIGAL
  • Like 1
Posted (edited)
17 hours ago, BIGAL said:

I noticed you have been trying to have a go so some hints

 

(defun c:d200

Get pt1 pt2 the dim points ask for a 3rd point for direction in or out. Near to pt1.

You can use the angle pt1 pt2 to work out  2 new offset points say from pt1 at 90 angle to the points, the closest distance to the pt3 is the one to use. ie the new pt4

Use (command "dim" "align"  pt1 pt2 pt4 "" "exit")

Just redo pt4 again for second dim (command "dim" "align"  pt1 pt2 pt4 "" "exit")

 

Have  ago we are here to help.

 

 

Could please give me some code to start with? I am still really raw and new to AutoLISP and this is too overwhelming for me :(

Edited by AeJay
Posted

Something like this.

 

(defun c:d200 ( / pt1 pt2)
(prompt "When asked points can be picked upside down to imply outward.")
(setq pt1 (getpoint "\nSelect 1st point on left "))
(setq pt2 (getpoint "\nSelect 2nd point on right "))
(setq ang (angle pt1 pt2))
(setq pt3 (polar pt1 (+ ang (/ pi 2.0)) 200))
(command "dim" "Align" pt1 pt2 pt3 "" "exit")
(setq pt3 (polar pt1 (+ ang (/ pi 2.0)) 300))
(command "dim" "Align" pt1 pt2 pt3 "" "exit")
(princ)
)

 

  • Thanks 1
Posted
On 4/2/2023 at 6:35 PM, BIGAL said:

Something like this.

 

(defun c:d200 ( / pt1 pt2)
(prompt "When asked points can be picked upside down to imply outward.")
(setq pt1 (getpoint "\nSelect 1st point on left "))
(setq pt2 (getpoint "\nSelect 2nd point on right "))
(setq ang (angle pt1 pt2))
(setq pt3 (polar pt1 (+ ang (/ pi 2.0)) 200))
(command "dim" "Align" pt1 pt2 pt3 "" "exit")
(setq pt3 (polar pt1 (+ ang (/ pi 2.0)) 300))
(command "dim" "Align" pt1 pt2 pt3 "" "exit")
(princ)
)

 

Thank you so much for this.

But how could I make it select via cross-window selection instead of selecting two points? I get an error of "bad point argument" with the code below.

(defun c:d200 (/ ss pt1 pt2 pt3 ang)
  (setq ss (ssget "_C"))
  (setq pt1 (cdr (assoc 10 (entget (ssname ss 0))))) 
  (setq pt2 (cdr (assoc 10 (entget (ssname ss 1)))))
  (setq ang (angle pt1 pt2))
  (setq pt3 (polar pt1 (+ ang (/ pi 2.0)) 200))
  (command "dim" "Align" pt1 pt2 pt3 "" "exit")
  (setq pt3 (polar pt1 (+ ang (/ pi 2.0)) 300))
  (command "dim" "Align" pt1 pt2 pt3 "" "exit")
(princ))


 

Posted

If its a pline you can pass the vertice points as pt1 pt2 and so on. You just need to check is pline Clock Wise or Counter CW. The reason being that implies go out not in. for a 4 sided shape you need to make sure that last dim is pt4 pt1. 

 

You could do a polygon and dim all sides.

 

A get all vertices.

(setq plent (entsel "\nPick rectang"))
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))
(setq co-ord (cons (last co-ord) co-ord)) ; adds 1st point as last point.

 

I would write a complete new version for plines.

 

Posted
16 hours ago, BIGAL said:

If its a pline you can pass the vertice points as pt1 pt2 and so on. You just need to check is pline Clock Wise or Counter CW. The reason being that implies go out not in. for a 4 sided shape you need to make sure that last dim is pt4 pt1. 

 

You could do a polygon and dim all sides.

 

A get all vertices.

(setq plent (entsel "\nPick rectang"))
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))
(setq co-ord (cons (last co-ord) co-ord)) ; adds 1st point as last point.

 

I would write a complete new version for plines.

 

Could you please try and combine it? I tried but I could not get it to work.

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