Jump to content

change getpoint axis value


Ajmal

Recommended Posts

how can I change “GETPOINT” z-axis value? I need always z-axis value “0”.

Because when I am taking with getpoint, one line distance if the line has z axis that also it will come to that length. Am drafting 2d I don’t want 3d. so when I will get the quantity it's coming wrong

(defun c:test()
  
  (vl-load-com)

(setq acadobj (vlax-get-acad-object)
      doc     (vla-get-activedocument acadobj))

(setq pt1     (vla-getpoint (vla-get-utility doc) nil "\nPick 1st point for length")
      pt1v (vlax-variant-value pt1)
      pt1zv  (vlax-safearray-get-element pt1v 2))
 (vlax-safearray-put-element pt1v 2 100.00)
 (setq new-zvalue (vlax-safearray-get-element pt1v 2))

(setq pt2     (vla-getpoint (vla-get-utility doc) nil "\nPick 1st point for length")
      pt2v (vlax-variant-value pt2)
      pt2zv  (vlax-safearray-get-element pt2v 2))
 (vlax-safearray-put-element pt2v 2 100.00)
 (setq new-zvalue (vlax-safearray-get-element pt2v 2))


(entmake (list (cons 0 "line")(cons 8 "01-identity")(cons 10 pt1)(cons 11 pt2))))

 

Link to comment
Share on other sites

 

 

(setvar 'osnapz 1) ; 2D

(setvar 'elevation 100.) ;plan elevation

(defun c:test ( / pt1 pt2)
  (ai_sysvar '(("OSNAPZ" . 1)("ELEVATION" . 100.0 ))) 
  (and (setq pt1 (getpoint "\nPick 1st point for length "))
       (setq pt2 (getpoint pt1 "\nPick 2nd point for length "))
       (entmakex    (vl-list* '(0 . "line")
              '(8 . "01-identity")
              (mapcar ''((a b) (cons a (trans b 1 0))) '(10 11) (list pt1 pt2))
              )
        )
       )
  (ai_sysvar nil) ; restore sysvar
  (princ)
  )

 

 

 

  • Like 1
Link to comment
Share on other sites

hanphuc provided a good solution sometimes the point is xyz but Autocad input is XY so a simple work around is

 

(setq pt1 (getpoint "\nPick 1st point for length "))
(setq pt1 (list (car pt1)(cadr pt1)))

 

Link to comment
Share on other sites

 

On 5/17/2020 at 6:04 PM, Ajmal said:

I need always z-axis value “0”.

 

(setvar 'elevation 0.000) or edit previous code

(defun c:test ( / pt1 pt2)
  (ai_sysvar '(("OSNAPZ" . 1)("ELEVATION" . 0.000 ))) 
  ;;<snippet>

BIGAL 's 1+3 others to suppress z , i.e. x,y only

 

1.scale 1 unit

(mapcar '* '(1. 1.) pt1)

2.butlast

(cdr (reverse (cdr pt1))

3.LM's addition

(mapcar '+ '(0 0) pt1)
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...