Jump to content
Drolma

Getpoint error

Recommended Posts

Drolma

I keep getting an error when I use getpoint. When I look at SPT or EPT it's nil

(defun c:STUD15 (/ SPT EPT Wallth Ceilinghg)

(setq SPT (getpoint "\nPick start of wall....."))

(setq EPT (getpoint "\nPick end of wall....."));at this point I get...error: bad argument type: 2D/3D point: nil

(setq Wallth (distance spt ept));length of wall

(setq Ceilinghgt 96.0)

(setq UnflrBeamhgt (+ Ceilinghgt 0.5));

Can someone explain what I am doing wrong.

Thanks

Share this post


Link to post
Share on other sites
broncos15
I keep getting an error when I use getpoint. When I look at SPT or EPT it's nil

(defun c:STUD15 (/ SPT EPT Wallth Ceilinghg)

(setq SPT (getpoint "\nPick start of wall....."))

(setq EPT (getpoint "\nPick end of wall....."));at this point I get...error: bad argument type: 2D/3D point: nil

(setq Wallth (distance spt ept));length of wall

(setq Ceilinghgt 96.0)

(setq UnflrBeamhgt (+ Ceilinghgt 0.5));

Can someone explain what I am doing wrong.

Thanks

You localized your variables. Unlocalize them while you test it and do !SPT to get the value. I am not getting any errors when testing it on a Pline.

Share this post


Link to post
Share on other sites
Drolma

Thanks for the quick response. Excuse my ignorance but does unlocalise mean drop the C: or just remove the variables from the ( ).

Share this post


Link to post
Share on other sites
satishrajdev

Localising means

(defun c:STUD15 [b][color="red"](/ SPT EPT Wallth Ceilinghg)[/color][/b]

 

Unlocalising it

(defun c:STUD15 [b][color="red"]( )[/color][/b]

Share this post


Link to post
Share on other sites
Drolma

I unlocalised the variables but I still get the same error message error: bad argument type: 2D/3D point: nil

Share this post


Link to post
Share on other sites
broncos15
I unlocalised the variables but I still get the same error message error: bad argument type: 2D/3D point: nil
What are you selecting when you get the error? Also, what portion of the code gives you the error?

Share this post


Link to post
Share on other sites
Drolma

I do a getpoint for the start and another getpoint for the end of a lwpolyline and the response from the second getpoint is....

 

(defun c:STUD15 ( ); I tried local. and unlocal.

(setq SPT (getpoint "\nPick start of wall....."))

(setq EPT (getpoint "\nPick end of wall....."));at this point I get...error: bad argument type: 2D/3D point: nil

 

Thanks for your help I do appreciate it!!!

Share this post


Link to post
Share on other sites
Drolma

I did a test as below and it gives me a good response but I don't see how it is different from the code with the problem???

(defun c:test4 (/ SPT EPT PT1 PT2 )

(setq SPT (getpoint "\nPick end of wall....."))

(setq EPT (getpoint "\nPick end of wall....."))

(setq ang1 (angle spt ept));length of wall

(princ ang1)

)

This gives me the radians of a horizontal pline 6.28

Share this post


Link to post
Share on other sites
broncos15
I did a test as below and it gives me a good response but I don't see how it is different from the code with the problem???

(defun c:test4 (/ SPT EPT PT1 PT2 )

(setq SPT (getpoint "\nPick end of wall....."))

(setq EPT (getpoint "\nPick end of wall....."))

(setq ang1 (angle spt ept));length of wall

(princ ang1)

)

This gives me the radians of a horizontal pline 6.28

That is strange, did you post all of your code so far? Because if you did, you were missing an ending ). There is probably some issue in another portion. When you post code, make sure to start it with [.code] and end with [./code], except don't do it with the periods in it.

Share this post


Link to post
Share on other sites
Drolma

Here is the routine that works with PT1 set to o,o,o. but when I tried (in previous post)to set SPT to a "getpoint" the routine fails.

;;This program is to draw a 3d model of a studwall
(defun c:STUDwall ( )
(setq PT1 (list 0 0 0))
(setq Ceilinghgt 96.0)
(setq UnflrBeamhgt (+ Ceilinghgt 0.5));Gyproc thickness 0.5 off floor.
(setq Wallth 180.0)
(setq Width 3.5)
(setq Hdrlth (+ Wallth Width))  
(setq Thk 1.5)
(setq Studlth (- UnflrBeamhgt(* Thk 3)))
(setq PT5x  (car PT1))                                              
(setq PT5y  (cadr PT1))                                                
(setq PT5z  (+(last PT1)1.5))
(setq PT5  (list PT5x PT5y PT5z)) 
(setq PT2 (polar PT5 6.283185307 Thk))
(setq PT3 (polar PT2 1.570796327 Width))       
(setq PT4 (polar PT3 3.141592654 Thk))
(command "pline" PT5 PT2 PT3 PT4 PT5 "")
(setq Wallstud (entlast )) 
(setq PT6 (polar PT1 6.283185307 Hdrlth))       
(setq PT7 (polar PT6 1.570796327 Width))
(setq PT8 (polar PT7 3.141592654  Hdrlth))
(setq PT9x  (car PT1))                                              
(setq PT9y  (cadr PT1))                                                
(setq PT9z  (+(last PT1)91.5))
(setq PT9  (list PT9x PT9y PT9z)) 
(command "pline" PT1 PT6 PT7 PT8 PT1 "")
(setq Wallhdr (entlast ))
(command "extrude" Wallhdr "" Thk )
(setq HdrFtr (entlast))
(command "extrude" Wallstud "" Studlth )
(setq Stud (entlast))
(setq PT10x  (car PT5))                                              
(setq PT10y  (cadr PT5))                                                
(setq PT10z  (+(last PT5)Studlth))
(setq PT10  (list PT10x PT10y PT10z))
(setq PT11x  (car PT10))                                              
(setq PT11y  (cadr PT10))                                                
(setq PT11z  (+(last PT10)1.5))
(setq PT11  (list PT11x PT11y PT11z))
(setq PT12x  (+(car PT1)(- Hdrlth 1.5)))                                              
(setq PT12y  (cadr PT1))                                                
(setq PT12z  (last PT1))
(setq PT12  (list PT12x PT12y PT12z))  
(command "copy"  Hdrftr "" PT1  PT10 )
(setq Hdr1 (entlast))
(command "copy"  Hdr1 "" PT10  PT11)
(setq Hdr2 (entlast))
(command "copy"  stud "" PT1  PT12)
(setq Laststud (entlast))
(command "copy"  laststud "" "" -1.5 0 0 )
(setq Secondlast (entlast))
(command "copy"  secondlast "" "" -1.5 0 0 )
(setq NumStuds (/ (+ Wallth width)16))
(setq Nstud (fix NumStuds))
(command "array" stud "" "r" "1" Nstud 16 )
(command "copy"  stud "" "" 1.5 0 0 )
(setq Firstud (entlast))
(command "copy"  Firstud "" "" 1.5 0 0 )
(princ)(princ)
) 

Share this post


Link to post
Share on other sites
broncos15
Here is the routine that works with PT1 set to o,o,o. but when I tried (in previous post)to set SPT to a "getpoint" the routine fails.

;;This program is to draw a 3d model of a studwall
(defun c:STUDwall ( )
(setq PT1 (list 0 0 0))
(setq Ceilinghgt 96.0)
(setq UnflrBeamhgt (+ Ceilinghgt 0.5));Gyproc thickness 0.5 off floor.
(setq Wallth 180.0)
(setq Width 3.5)
(setq Hdrlth (+ Wallth Width))  
(setq Thk 1.5)
(setq Studlth (- UnflrBeamhgt(* Thk 3)))
(setq PT5x  (car PT1))                                              
(setq PT5y  (cadr PT1))                                                
(setq PT5z  (+(last PT1)1.5))
(setq PT5  (list PT5x PT5y PT5z)) 
(setq PT2 (polar PT5 6.283185307 Thk))
(setq PT3 (polar PT2 1.570796327 Width))       
(setq PT4 (polar PT3 3.141592654 Thk))
(command "pline" PT5 PT2 PT3 PT4 PT5 "")
(setq Wallstud (entlast )) 
(setq PT6 (polar PT1 6.283185307 Hdrlth))       
(setq PT7 (polar PT6 1.570796327 Width))
(setq PT8 (polar PT7 3.141592654  Hdrlth))
(setq PT9x  (car PT1))                                              
(setq PT9y  (cadr PT1))                                                
(setq PT9z  (+(last PT1)91.5))
(setq PT9  (list PT9x PT9y PT9z)) 
(command "pline" PT1 PT6 PT7 PT8 PT1 "")
(setq Wallhdr (entlast ))
(command "extrude" Wallhdr "" Thk )
(setq HdrFtr (entlast))
(command "extrude" Wallstud "" Studlth )
(setq Stud (entlast))
(setq PT10x  (car PT5))                                              
(setq PT10y  (cadr PT5))                                                
(setq PT10z  (+(last PT5)Studlth))
(setq PT10  (list PT10x PT10y PT10z))
(setq PT11x  (car PT10))                                              
(setq PT11y  (cadr PT10))                                                
(setq PT11z  (+(last PT10)1.5))
(setq PT11  (list PT11x PT11y PT11z))
(setq PT12x  (+(car PT1)(- Hdrlth 1.5)))                                              
(setq PT12y  (cadr PT1))                                                
(setq PT12z  (last PT1))
(setq PT12  (list PT12x PT12y PT12z))  
(command "copy"  Hdrftr "" PT1  PT10 )
(setq Hdr1 (entlast))
(command "copy"  Hdr1 "" PT10  PT11)
(setq Hdr2 (entlast))
(command "copy"  stud "" PT1  PT12)
(setq Laststud (entlast))
(command "copy"  laststud "" "" -1.5 0 0 )
(setq Secondlast (entlast))
(command "copy"  secondlast "" "" -1.5 0 0 )
(setq NumStuds (/ (+ Wallth width)16))
(setq Nstud (fix NumStuds))
(command "array" stud "" "r" "1" Nstud 16 )
(command "copy"  stud "" "" 1.5 0 0 )
(setq Firstud (entlast))
(command "copy"  Firstud "" "" 1.5 0 0 )
(princ)(princ)
) 

It works fine on my machine if I put in:
(setq PT1 (getpoint "\nPick a point: "))

What happens on your machine if you do that? Also, you have an extra princ at the end of the code.

Share this post


Link to post
Share on other sites
Lee Mac

After a cursory glance, I've added a few corrections and condensed a few of the expressions - the following may still contain typos and is untested, but hopefully will help:

;;This program is to draw a 3d model of a studwall

(defun c:STUDwall ( / ceilinghgt firstud hdr1 hdr2 hdrftr hdrlth laststud pt1 pt10 pt11 pt12 pt2 pt3 pt4 pt5 pt6 pt7 pt8 pt9 secondlast stud studlth thk unflrbeamhgt wallhdr wallstud wallth width )
   (if (setq pt1 (getpoint "\nPick point: "))
       (progn
           (setq Ceilinghgt    96.0
                 UnflrBeamhgt  (+ Ceilinghgt 0.5) ; Gyproc thickness 0.5 off floor.
                 Wallth        180.0
                 Width         3.5
                 Hdrlth        (+ Wallth Width)
                 Thk           1.5
                 Studlth       (- UnflrBeamhgt (* Thk 3))  
                 PT5           (list (car PT1) (cadr PT1) (+ (last PT1) 1.5))
                 PT2           (polar PT5 0 Thk)
                 PT3           (polar PT2 (/ pi 2) Width)
                 PT4           (polar PT3 pi Thk)
           )
           (command "_.pline" "_non" PT5 "_non" PT2 "_non" PT3 "_non" PT4 "_non" PT5 "")
           (setq Wallstud (entlast)
                 PT6      (polar PT1 0 Hdrlth)
                 PT7      (polar PT6 (/ pi 2) Width)
                 PT8      (polar PT7 pi Hdrlth)
                 PT9      (list (car PT1) (cadr PT1) (+ (last PT1) 91.5))
           )
           (command "_.pline" PT1 "_non" PT6 "_non" PT7 "_non" PT8 "_non" PT1 "")
           (setq Wallhdr (entlast))
           (command "_.extrude" Wallhdr "" Thk)
           (setq HdrFtr (entlast))
           (command "_.extrude" Wallstud "" Studlth)
           (setq Stud  (entlast)
                 PT10  (list (car PT5)  (cadr PT5)  (+ (last PT5) Studlth))
                 PT11  (list (car PT10) (cadr PT10) (+ (last PT10) 1.5))
                 PT12  (list (+ (car PT1) (- Hdrlth 1.5)) (cadr PT1) (last PT1))
           )
           (command "_.copy" Hdrftr "" "_non" PT1 "_non" PT10)
           (setq Hdr1 (entlast))
           (command "_.copy" Hdr1 "" "_non" PT10 "_non" PT11)
           (setq Hdr2 (entlast))
           (command "_.copy" stud "" "_non" PT1 "_non" PT12)
           (setq Laststud (entlast))
           (command "_.copy" laststud "" "" "_non" '(-1.5 0 0))
           (setq Secondlast (entlast))
           (command 
               "_.copy" secondlast "" "" "_non" '(-1.5 0 0)
               "_.array" stud "" "r" "1" (fix (/ (+ Wallth width) 16)) 16
               "_.copy"  stud "" "" "_non" '(1.5 0 0)
           )
           (setq Firstud (entlast))
           (command "_.copy" Firstud "" "" "_non" '(1.5 0 0))
       )
   )
   (princ)
)

Share this post


Link to post
Share on other sites
BIGAL

I am like others it works ? Any way another way of doing 3d walls. Using thickness.

3dhouse.jpg

Edited by BIGAL

Share this post


Link to post
Share on other sites
Drolma

Thanks Big AL and Lee Mac I will try your revised routine, thanks.

Share this post


Link to post
Share on other sites
Drolma

Lee Mac thanks it works. I have not seen _non before, but that seems to have done the trick. When I looked at !spt before your fix the y coord was a very small figure -2.346..e 13 do you have any idea what would cause that. Could it be unit precision settings or something else?

Thanks

Share this post


Link to post
Share on other sites
Lee Mac
Lee Mac thanks it works.

 

Good stuff :thumbsup:

 

I have not seen _non before, but that seems to have done the trick.

 

See the first section of my tutorial here for an explanation.

 

When I looked at !spt before your fix the y coord was a very small figure -2.346..e 13 do you have any idea what would cause that. Could it be unit precision settings or something else?

 

Such values are typically caused by the rounding of double-precision floating-point numbers (aka doubles, or reals in AutoLISP); -2.3456e-13 is exponential notation for -0.00000000000023456, i.e. an incredibly small number. This is therefore likely to be the result of applying arithmetic operations to 0.0, resulting in incredibly small rounding errors creeping into every calculation.

 

Such rounding errors are unavoidable by the very nature of the floating-point format, as storing numbers to an infinite level of precision would require an infinite amount of memory. Doubles occupy 64-bits of memory (8 bytes), which allows for approximately 15 significant figures of precision.

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