line not shown in current view

line not shown in current view

jaggisingh003
Advocate Advocate
1,204 Views
12 Replies
Message 1 of 13

line not shown in current view

jaggisingh003
Advocate
Advocate

hello, Everyone please help me here.

I m working on something but get a problem whenever I execute this code in the current view this does not draw this  (command ".line" h st1 "") but whenever run this not in current view then this will work perfectly. I don't understand the problem. 

 

(defun c:bkt (/ a l e f b a q h
p1 bk st1 st_l st_1 bt1 bt_1 st_inspt
bt_inspt st_y st
)
(setq l 2.90) ;(getreal "\n get the Setting distance")
(setq bk 2.00)
(setq e 1.400) ;(getreal "\n get the encumbrance")
(setq f 0.3)
(setq st_inspt 1.25)
(setq bt_inspt 2.5365)
(setq os (getvar "OSMODE"))
(setq b
(expt
(- (+ (expt (- l 0.2) 2) (expt (+ (- (+ e f) 0.156) 0.0705) 2))
(expt 0.110 2)
)
0.5
)
)
(setq q (/ (- (+ e f) 0.0855) (- l 0.200)))
(setq ang (+ (atan q) (atan (/ 0.11 b))))
(setq a
(expt (+ (expt (- bk (+ (+ e f) (+ (* 0.160 (cos ang)) 0.0705))) 2)
(expt (- (- l 0.125) (* 0.160 (sin ang))) 2)
)
0.5
)
)
(setq p1 (getpoint "\n get the start point"))
; get insertion point of bkt
(setq h (polar p1 (angtof "90.0") 20.0))
(command ".line" p1 h "")
(setq st1 (polar h (angtof "0.0") 1.25))
;mm line form last point of bkdist
(command ".line" h st1 "") ; draw line
(setq st_l (entlast)) ; set last drawn line st_l
(setq st_y (vlax-curve-getendpoint st_l))  ; get end point coordinates

(setq a (* 10 a))
(setq st_1 (polar st_y (angtof "0.0") a))
;final stay brkt length
(command ".line" st_y st_1 "")
(setq st (entlast));stay brkt for dimension
(setvar "OSMODE" os)
)

0 Likes
Accepted solutions (1)
1,205 Views
12 Replies
Replies (12)
Message 2 of 13

dlanorh
Advisor
Advisor
This looks like you need to (trans) the getpoint coords to wcs then trans st_y and st_1 to usc before drawing the line.

I am not one of the robots you're looking for

0 Likes
Message 3 of 13

jaggisingh003
Advocate
Advocate

@dlanorh. thanks for your suggestion I am new to lisp any example for this function. for more  help 

 

0 Likes
Message 4 of 13

jaggisingh003
Advocate
Advocate

@dlanorh.  this not working (trans) Any other Suggestion

0 Likes
Message 5 of 13

jaggisingh003
Advocate
Advocate

This is happening with this code.

0 Likes
Message 6 of 13

dlanorh
Advisor
Advisor

How did you change the code?

 

(setq p1 (trans (getpoint "\n get the start point") 1 0)); getpoint = ucs insertion point of bkt so trans to wcs
(setq h (polar p1 (angtof "90.0") 20.0)); calc h in wcs
(command ".line" (trans p1 0 1) (trans h 0 1) "") ;draws line in ucs
(setq st1 (polar h (angtof "0.0") 1.25)) ;calc in wcs mm line form last point of bkdist
(command ".line" (trans h 0 1) (trans st1 0 1) "") ; draw line in ucs
(setq st_l (entlast)) ; set last drawn line st_l
(setq st_y (vlax-curve-getendpoint st_l))  ; get end point coordinates pt returned in wcs

(setq a (* 10 a))
(setq st_1 (polar st_y (angtof "0.0") a));final stay brkt length calc in wcs
(command ".line" (trans st_y 0 1) (trans st_1 0 1) "");draw in ucs

 

I hardly ever work in a ucs, so I'm very rusty, but substitute the above in your code lisp and see if this helps.

 

getpoint returns the point in the ucs so it needs to be transformed into wcs

vlax-curve-getendpoint returns a point in wcs

 

if all calculations are made in wcs and the points transformed to ucs when drawn you should end up with the correct geometry 🤞

 

If a coordinate is already in wcs, transforming it to wcs has no effect.

I am not one of the robots you're looking for

Message 7 of 13

jaggisingh003
Advocate
Advocate

@dlanorh thanks for this but not working 😭 😭.

0 Likes
Message 8 of 13

Kent1Cooper
Consultant
Consultant

Turn off running Object Snap and try again.  [This is almost always the source of the problem when things are not drawn where you expect them to be.]

 

My guess is that this:

 

(command ".line" h st1 "")

 

is finding 'h' to be within the Object Snap aperture distance from 'st1', and is snapping [back] to the 'h' location.  When it fails, do you get a zero-length Line there at the corner?  And I'm guessing that somehow Osnap isn't in effect outside the viewing area, so that doesn't happen out there.

Kent Cooper, AIA
Message 9 of 13

jaggisingh003
Advocate
Advocate

@Kent1Cooper  do you get a zero-length Line there at the corner? -yes

yes getting a zero-length line.

0 Likes
Message 10 of 13

Kent1Cooper
Consultant
Consultant

@jaggisingh003 wrote:

@Kent1Cooper  do you get a zero-length Line there at the corner? -yes

yes getting a zero-length line.


That is what I expected.  So have you tried running it with Osnap off?

Kent Cooper, AIA
0 Likes
Message 11 of 13

jaggisingh003
Advocate
Advocate

 @Kent1Cooper  So what to do in this matter pls help  and tell me what to do.

0 Likes
Message 12 of 13

Kent1Cooper
Consultant
Consultant
Accepted solution

@jaggisingh003 wrote:

 @Kent1Cooper  So what to do in this matter pls help  and tell me what to do.


I did already.  See the beginning of Message 8.  This from your screencast indicates that you have it turned on:

OsnapIsOn.PNG

Kent Cooper, AIA
Message 13 of 13

jaggisingh003
Advocate
Advocate

thanks for your reply it helps me.

0 Likes