Jump to content

draw plines in inches (metric CAD file)


Recommended Posts

Posted

I have found this LISP on another website to input inches in metric environment.

Question: is it possible to use similar methods to upon executing the command (say PL1), start pline in inches in a metric cad file?

I do realize that some of you would comment why not convert it after you draw it or why not scale... I just needed to know if there is a way to draw in this way??

Thanks,

 

;An offset command in inches
;If you have to do an offset while
;in an metric drawing this does it
(defun C:2( / d)
(setq d (getdist "Input distance (in): ")); in inches
(setq d (* d 25.40))                  ; converts it to mm
(command "._offset" d)                  ;sends value to offset command
)

Posted

(defun c:PL1(/ d p1 s)
  (setq d (getreal "Input (in): "))(terpri)
  (setq p1 (getpoint "Pick first point" ))(terpri) 
  (setq s (* d 25.4)) 
  (command "._pline" p1 ....... s)  <something to draw from here on with the conversion>
  (princ)
  )

Posted (edited)

If you treat it as a transparent command may work with some commands.

 

(defun c:2 ( /)(* (getreal) 25.4))

eg line startpt drag mouse '2 4 drag '2 6

eg pline startpt '2 4 '2 6 '2 6 '2 5 c

 

One thing though living in the land of metric depending on what your building should rounding be considered ? Would you build 100 or 101.6 a foot is 304 mm should you do it 300 mm if using say cut timber sheets they are exactly mm sizes like 1200x900 not  1219.2 x914.4 that 14.4mm would be a real problem 19.2 even bigger problem.

Edited by BIGAL
Posted

This is great BIGAL.

 

it seems there is nothing you cannot do. It is actually nice to see that this works on all commands. Job WELL DONE!- so here is the follow up question...

Is it then possible to have '3 for inputting feet&inches, example '2 4&8 = 4 feet and 8 inches (1st * 304.8 & 2nd * 25.4) ?

 

Thanks again

Posted

Try

 

(defun c:3 ( / )
(command (+ (* (getreal) 304.8 )(* (getreal) 25.4)))
)

 

Posted (edited)
On 10/22/2019 at 1:35 AM, Sambuddy said:

I have found this LISP on another website to input inches in metric environment.

Question: is it possible to use similar methods to upon executing the command (say PL1), start pline in inches in a metric cad file?

I do realize that some of you would comment why not convert it after you draw it or why not scale... I just needed to know if there is a way to draw in this way??

Thanks,

 

;An offset command in inches
;If you have to do an offset while
;in an metric drawing this does it
(defun C:2( / d)
(setq d (getdist "Input distance (in): ")); in inches
(setq d (* d 25.40))                  ; converts it to mm
(command "._offset" d)                  ;sends value to offset command
)

 

hi without code try: CAL

 

Command: _offset
Current settings: Erase source=No  Layer=Source  OFFSETGAPTYPE=0
Specify offset distance or [Through/Erase/Layer] <3.000>: 'cal
>>>> Expression: 24.5*3

Resuming OFFSET command.

Specify offset distance or [Through/Erase/Layer] <3.000>: 73.5

 

example 3'ft 4"inch

or use global variable f=foot i=inch

Command: (setq f 304.8 i 25.4)
25.4

Command: cal
>> Expression: 3*f+4*i
1016

Edited by hanhphuc
Posted (edited)

Hanhphuc  cal has a heap of smart functions and is hardly ever used. I often use it to just do like multiply. you can do all sorts of things like 2 * rad for offset etc. bit slow though if having to type all the time.

 

The better way is to do a draw by brg distance function. 

 

This is one I prepared earlier said the chef

; input feet then inches then fractions as many as required.
; 123.11.5 is 123 feet 11 inches + 0.5 of a inch 3/8 is 0.375

 

Another maybe

image.png.106a4f5fc6eef310267c8b452a630fc6.png

Edited by BIGAL
Posted (edited)
49 minutes ago, BIGAL said:

Hanhphuc  cal has a heap of smart functions and is hardly ever used. I often use it to just do like multiply. you can do all sorts of things like 2 * rad for offset etc. bit slow though if having to type all the time.

 

The better way is to do a draw by brg distance function. 

 

This is one I prepared earlier said the chef

; input feet then inches then fractions as many as required.
; 123.11.5 is 123 feet 11 inches + 0.5 of a inch 3/8 is 0.375

 

Another maybe

image.png.106a4f5fc6eef310267c8b452a630fc6.png

nice @BIGAL :) it would be nice extra DEG MIN SEC format

 

 

slightly tweak from this old thread adding argument for scale factor

 

(dt_dd_mm_ss  25.4  "0.19685  36 52 12")
returns (4.99999 0.643503) ;distance & angle (related to user units sysvar i.e: angdir , angbase)

;function
(defun dt_dd_mm_ss (f str / l) ; return list (dist angle)
 (if (and str
          (setq l (read (strcat "(" str ")")))
          (vl-every 'numberp l)
          (and (<= 0. (cadr l)) (< (cadr l) 360.))
          (vl-every ''((x) (and (<= 0. x) (< x 60.))) (cddr l))
          )
   (list (* (car l) f)
         (angtof
           (apply 'strcat
                  (mapcar ''((a b c) (strcat (rtos a 2 c) b)) (cdr l) '("d" "'" "\"") '(0 0 2))
                  )
           )
         )
   )
 )

;;example simulate command line:
(defun c:myline (/ p1 p2 l *error*)
 (defun *error* (msg) nil)
 (setq p1 (getpoint "\nSpecify 1st point: "))
 (while (setq p2 (if (vl-consp (setq p2 (getpoint p1 "\nSpacebar for [_dist_dd_mm_ss] : ")))
	    p2
	    (progn (while (not (setq l (dt_dd_mm_ss 25.4 (getstring t "\nINCH_dd_mm_ss  : \n")))))
		   (apply 'polar (cons p1 (reverse l)))
		   )
	    )
       )
   (entmakex (list '(0 . "LINE") (cons 10 (trans p1 1 0)) (cons 11 (trans p2 1 0))))
   (setq p1 p2)
   )
 (princ)
 )

 

Edited by hanhphuc
Posted (edited)

Hanhphuc your right about the bearing I normally use ddd.mmss have done so since the 1990's. Working in metric just makes life so much easier.

 

Here in Aus we have old land titles down  to 1/4", then there are roods and chains to worry about.

 

Nice routine though combing the distance and bearing into a string. I would have used dist.dec,DDD.mmss so no problems with a space terminating a string input.

 

If you want end result as pline do a cons of (entlast) as you make lines can then join them into a pline at end or pedit last and join new as you go.

 

The multi getvals.lsp  above can have the default reset every time if you want for distance and bearing save a bit of typing as you may say do repeated brg's but different lengths.

 

It can though be all to no avail, for here in say AUS, old towers would have been built to say inch standard, new towers are possibly now true metric sizes. A lot of stuff though is still built to old standards. 

 

Edited by BIGAL
Posted (edited)
On 10/23/2019 at 11:32 AM, BIGAL said:

 

If you want end result as pline do a cons of (entlast) as you make lines can then join them into a pline at end or pedit last and join new as you go.

 

 

 

 

 

or make it transparent for polyline or others command move etc..

(defun c:dd ( / str ) (if (and (setq str (getstring t "\nDISTANCE_dd_mm_ss : ")) (setq l (dt_dd_mm_ss 1.0 str)))
  (apply 'polar (cons (getvar 'lastpoint) (reverse l)))(princ))
  )

 

example drawing triangle:

Command: (vl-cmdf "-units" 2 3 2 4 90 "Y" )  <-- 2=Degrees/minutes/seconds

...

...

Command: PLINE

Specify start point: 0,0

Current line-width is 0.0000
Specify next point or [Arc/Halfwidth/Length/Undo/Width]: 'dd
DIST_dd_mm_ss : 5 36 52 12                <-- dist dd mm ss
(3.00001 3.99999 0.0)

Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: 3            <-- mouse pointing to west or polar tracking
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: 'dd

DIST_dd_mm_ss : 4 180
(7.14566e-006 -5.35926e-006 0.0)
 

 

Command: MOVE
Select objects: 1 found

Select objects:

Specify base point or [Displacement] <Displacement>:
Specify second point or <use first point as displacement>: 'dd

DIST_dd_mm_ss : 5 36 52 12       <-- should apply -ve distance? bug?
(3.00001 3.99999 0.0)

Edited by hanhphuc
syntax color , delete comment
Posted

I think we need Sambuddy to step up.

 

maybe Ft.inch,DDD.mmss  3.3,180.0 3 feet 3 inches but does not support fractions Hmm another problem.

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