; 1 form loaded from #<editor ""

; 1 form loaded from #<editor ""

Anonymous
Not applicable
1,758 Views
10 Replies
Message 1 of 11

; 1 form loaded from #<editor ""

Anonymous
Not applicable

Hi I was writing this code for a hw but I get the error ; 1 form loaded from #<editor "G:/CAD/HW 8/LBox.lsp"> when i try to load the code up.

; LBOX.lsp

(defun c:lbox ()

; Turn command echo and object snap off, and blip mode on
(setq scmde (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq sblip (getvar "blipmode"))
(setvar "blipmode" 1)
(setq sosmd (getvar "osmode"))
(setvar "osmode" 0)
(setq 3dosmd (getvar "3dosmode"))
(setvar "3dosmode" 0)
(setq dyucs (getvar "ucsdetect"))
(setvar "ucsdetect" 0)


; Input data for part
(setq pt1 (getpoint "\n Locate Lower Left Corner Point"))
(setq pt2 (getpoint "\n Locate Upper Right Corner Point"))
(setq H (getreal "\n Input Height of Part"))
(setq D (getreal "\n Input Diameter of Hole"))


; Change current color
(command "color" "red")


; Determine width of part
(setq A (- (car pt2) (car pt1)))


; Set locations of additional points
(setq pt3 (list (car pt2) (cadr pt2) (- H)))
(setq pt4 (list (car pt2) (cadr (/ (+ (cadr pt1) (cadr pt2)) 2)) (- H)))
(setq pt5 (list (car pt2) (car pt1) (- H)))


; Create solid
(command "box" pt1 pt3)
(setq e1 (entlast))
(command "arc" "c" pt4 pt5 pt3)
(setq e2 (entlast))
(command "line" pt3 pt5 "")
(command "region" e2 "l" "")
(command "extrude" "l" "" A)
(command "union" e1 "l" "")
(setq e3 (entlast))
(setq pt6 (list(car pt1) (cadr (/ (+ (cadr pt1) (cadr pt2)) 2))(- (/ (- (H A) 2)))))
(setq pt7 (list (car pt2) (cadr (/ (+ (cadr pt1) (cadr pt2)) 2)) (- (/ (- (H A) 2)))))


(command "color" "green")
(command "cylinder" pt6 (/ D 2) "A" pt7)
(command "subtract" e3 "" "l" "")
(setq pt8 (list (car pt1) (cadr pt1) (- H)))
(command "color" "blue")
(command "ucs" 3 pt8 pt5 pt1)
(command "text" (list 0.1 0.1) 0.3 0 "Robin")
(command "ucs" "w")
(command "vpoint" (list 1 -1 1))
(command "hide")

(setvar "blipmode" sblip)
(setvar "cmdecho" scmde)
(setvar "osmode" snp)
(setvar "3dosmode" 3dosmd)
(setvar "ucsdetect" dyucs)
)

HW8.PNG

 

0 Likes
Accepted solutions (1)
1,759 Views
10 Replies
Replies (10)
Message 2 of 11

ВeekeeCZ
Consultant
Consultant

Home assignment, right?

 

Just pointing on some errors...

 

(setq pt4 (list (car pt2) (cadr (/ (+ (cadr pt1) (cadr pt2)) 2)) (- H)))
(setq pt5 (list (car pt2) (car pt1) (- H)))


; Create solid
(command "box" pt1 pt3) ; something missing
(setq e1 (entlast))
(command "arc" "c" pt4 pt5 pt3) ; probably wrong calculation leads to R=0

... and probably more...

0 Likes
Message 3 of 11

Anonymous
Not applicable

is that why i would get the load error i cant really see any other error messages until this one is resolved i have never been good at coding so one error message at a time would be grateful.

0 Likes
Message 4 of 11

ВeekeeCZ
Consultant
Consultant

Well, "; 1 form loaded from #<editor "<Untitled-4> loading...">" is not really an error, that's the information that code was loaded.

 

Go to the cad, and run your program typing LBOX, then I receive the "Command: bad argument type: consp 476.868" error, which the first line I've bold before...

0 Likes
Message 5 of 11

Kent1Cooper
Consultant
Consultant

Some other issues:

 

Same problem @ВeekeeCZ pointed out about the setting of pt4, and another:

 

(setq pt6 (list(car pt1) (cadr (/ (+ (cadr pt1) (cadr pt2)) 2))(- (/ (- (H A) 2)))))
(setq pt7 (list (car pt2) (cadr (/ (+ (cadr pt1) (cadr pt2)) 2)) (- (/ (- (H A) 2)))))

 

But I don't know about the error message described -- whether fixing those issues identified will also fix that, I couldn't say.

Kent Cooper, AIA
0 Likes
Message 6 of 11

Anonymous
Not applicable

ok i fixed up the program but i still get and error when i run it ;error: bad argument type: consp 5.0

;Program to create a solid L-shaped object with cylindrical bottom and horizontal hole
;Robin 
; LBOX.lsp

(defun c:lbox ()

;Turn command echo and object snap off, and blip mode on
(setq scmde (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq sblip (getvar "blipmode"))
(setvar "blipmode" 1)
(setq sosmd (getvar "osmode"))
(setvar "osmode" 0)
(setq 3dosmd (getvar "3dosmode"))
(setvar "3dosmode" 0)
(setq dyucs (getvar "ucsdetect"))
(setvar "ucsdetect" 0)


;Input data for part
(setq pt1 (getpoint "\nLocate Lower Left Corner Point"))
(setq pt2 (getpoint "\nLocate Upper Right Corner Point"))
(setq H (getreal "\nInput Height of Part"))
(setq D (getreal "\nInput Diameter of Hole"))


;Change current color
(command "color" "red")


;Determine width of part
(setq A (- (car pt2) (car pt1)))


;Set locations of additional points
(setq pt3 (list (car pt2) (cadr pt2) (- H)))
(setq pt5 (list (car pt2) (car pt1) (- H)))
(setq pt4 (list (car pt2) (cadr (/ (+ (cadr pt5) (cadr pt3)) 2)) (- H)))



;Create solid
(command "box" pt1 pt3)
(setq e1 (entlast))
(command "arc" "c" pt4 pt5 pt3)
(setq e2 (entlast))
(command "line" pt3 pt5 "")
(command "region" e2 "l" "")
(command "extrude" "l" "" A)
(command "union" e1 "l" "")
(setq e3 (entlast))
(setq pt6 (list(car pt1)(cadr pt4)(/ (- H A) 2)))
(setq pt7 (list(car pt5)(cadr pt4)(/ (- H A) 2)))


(command "color" "green")
(command "cylinder" pt6 (/ D 2) "A" pt7)
(command "subtract" e3 "" "l" "")
(setq pt8 (list (car pt1) (cadr pt1) (- H)))
(command "color" "blue")
(command "ucs" 3 pt8 pt5 pt1)
(command "text" (list 0.1 0.1) 0.3 0 "ROBIN")
(command "ucs" "w")
(command "vpoint" (list 1 -1 1))
(command "hide")

(setvar "cmdecho" scmde)
(setvar "blipmode" sblip)
(setvar "3dosmode" 3dosmd)
(setvar "osmode" snp)
(setvar "ucsdetect" dyucs)
)
;End of program
0 Likes
Message 7 of 11

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

ok i fixed up the program but i still get and error when i run it ;error: bad argument type: consp 5.0


You didn't fix it all yet.  The first issue @ВeekeeCZ pointed out is still there:

(setq pt4 (list (car pt2) (cadr (/ (+ (cadr pt5) (cadr pt3)) 2)) (- H)))

 

The (cadr) function returns the second item in a list.  Your use there is as though it's supposed to supply  the Y coordinate, but it's used for extracting  Y coordinates from point coordinate lists.  The expression you're giving it as an argument results in a number, not a list.  And sure enough, the error message means that some function that is expecting to get a list  is getting a number  instead, and I'll bet that's the one.  Without evaluating too closely, removing the red parts should fix it, because what remains between them looks like it should be a viable Y coordinate.

Kent Cooper, AIA
0 Likes
Message 8 of 11

Anonymous
Not applicable

made more progress the will run a little more will give me everything but the cylinder cut and gives an error of Not enough free RAM for HIDE --some lines will be hidden incorrectly. ;error AutoCAD variable setting rejected: "osmode" nil

;Program to create a solid L-shaped object with cylindrical bottom and horizontal hole
;Robin
; LBOX.lsp

(defun c:lbox ()

;Turn command echo and object snap off, and blip mode on
(setq scmde (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq sblip (getvar "blipmode"))
(setvar "blipmode" 1)
(setq sosmd (getvar "osmode"))
(setvar "osmode" 0)
(setq 3dosmd (getvar "3dosmode"))
(setvar "3dosmode" 0)
(setq dyucs (getvar "ucsdetect"))
(setvar "ucsdetect" 0)


;Input data for part
(setq pt1 (getpoint "\nLocate Lower Left Corner Point"))
(setq pt2 (getpoint "\nLocate Upper Right Corner Point"))
(setq H (getreal "\nInput Height of Part"))
(setq D (getreal "\nInput Diameter of Hole"))


;Change current color
(command "color" "red")


;Determine width of part
(setq A (- (car pt2) (car pt1)))


;Set locations of additional points
(setq pt3 (list (car pt2) (cadr pt2) (- H)))
(setq pt5 (list (car pt2) (cadr pt1) (- H)))
(setq pt4 (list (car pt2) (/ (+ (cadr pt2) (cadr pt5)) 2) (- H)))



;Create solid
(command "box" pt1 pt3)
(setq e1 (entlast))
(command "arc" "c" pt4 pt5 pt3)
(setq e2 (entlast))
(command "line" pt3 pt5 "")
(command "region" e2 "l" "")
(command "extrude" "l" "" A)
(command "union" e1 "l" "")
(setq e3 (entlast))
(setq pt6 (list (car pt1) (cadr pt4) (/ (- H A) 2)))
(setq pt7 (list (car pt5) (cadr pt4) (/ (- H A) 2)))


(command "color" "green")
(command "cylinder" pt6 (/ D 2) "A" pt7)
(command "subtract" e3 "" "l" "")
  
(setq pt8 (list (car pt1) (cadr pt1) (- H)))
(command "color" "blue")
(command "ucs" 3 pt8 pt5 pt1)
(command "text" (list 0.1 0.1) 0.3 0 "ROBIN")
(command "ucs" "w")
(command "vpoint" (list 1 -1 1))
(command "hide")

(setvar "cmdecho" scmde)
(setvar "blipmode" sblip)
(setvar "3dosmode" 3dosmd)
(setvar "osmode" snp)
(setvar "ucsdetect" dyucs)
)
;End of program
0 Likes
Message 9 of 11

dbroad
Mentor
Mentor

I'm curious about how the teacher who assigned this project will react when he discovers this student has turned in group work and publicized a solution to the rest of the class that short circuits most of the learning process for them.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 10 of 11

Anonymous
Not applicable

1: its past due so i already handed in my mess of a code

2: I'm trying to learn and figure out why it is wrong.

3: I am allowed to ask my peers to trouble shoot. Which I already did and they have no idea why it won't make the cylinder.

0 Likes
Message 11 of 11

dbroad
Mentor
Mentor

In order to build a class learning community, I think the peers your teacher may have been thinking about were your fellow students rather than a public forum.  Get the teacher to post here and I would be very willing to contribute, if that helps.

Architect, Registered NC, VA, SC, & GA.
0 Likes