Why instead of HPANG, a number between 0 and 1 is loaded?

Why instead of HPANG, a number between 0 and 1 is loaded?

Anonymous
Not applicable
934 Views
14 Replies
Message 1 of 15

Why instead of HPANG, a number between 0 and 1 is loaded?

Anonymous
Not applicable
Hello, I wrote an lisp which (DEFUN C:HNGGCUR (/ CurANG) (setq CurANG (getvar "HPANG")) (setq zbior (ssget)) (princ "\nSelect Hatch Patterns to change their HatchAngle for the Current HatchAngle") (COMMAND "_-HATCHEDIT" zbior "Properties" "" "" CurANG ) ) (HNGGCUR = Hatch aNGle CURrent) (CurANG = Current Angle for Hatch Patterns) But it doesn't work properly. For example, I set HPANG=45 and type HNGGCUR, but after that command, Angle of Hatch is equal to 0 or 1. To check the value of HPANG, I wrote a lisp: (DEFUN C:HNGINF (/) (princ "\nCurrent HatchAngle: " ) (getvar "HPANG") ) (HNGINF = Hatch aNGle INFo) I typed HPANG and set it for 44, and then I typed HNGINF, but it doesnt give me the answer "44", but "0.767945". So that is why the numbers 0 or 1 appeared as HatchAngle after the HNGGCUR command. Here is what appeared in CommandLine: Command: HPANG Enter new value for HPANG <44>: Command: HNGINF Current HatchAngle: 0.767945 What does that number mean? Why the HPANG is not properly loaded? Why the lisp HNGGCUR doesn't work? What is wrong? Please, help.
0 Likes
935 Views
14 Replies
Replies (14)
Message 2 of 15

Anonymous
Not applicable
I don't know why my post which is shown above doesn't have new paragraphs, although when I wrote this post, I made the new paragraphs. And I add a .txt file which shows in which way I wrote my post.
0 Likes
Message 3 of 15

Anonymous
Not applicable
In previos post I clicked on "add attachment" and after that, top of the page was shown. BUt finally it didn't get added. I don't know in what way I should post on this forum in right way. This is my next problem. Please, could you help me?
0 Likes
Message 4 of 15

Ajilal.Vijayan
Advisor
Advisor

@Anonymous wrote:
Command: HPANG Enter new value for HPANG <44>: Command: HNGINF Current HatchAngle: 0.767945 What does that number mean? Why the HPANG is not properly loaded? Why the lisp HNGGCUR doesn't work? What is wrong? Please, help.

Hi,

0.767945 is the value in radians which is equal to 44 degrees.

 

This is the function to convert the degrees to radians.

(* pi (/ 44 180.0)))

 Regarding the file attachment to this forum, there are some limitations to some file types.

So you need to either zip or use a text file extension to attach the lisp file.

 

As you said, its hard to read the code from your first post.

If you manage to attach the lisp file, or use the code tag to insert the lisp code, we will be able to look at the code as well.

 

Note:- Please note that there is a forum dedicated to Lisp, as this post more related to lisp you should use that forum for more traffic.

 

 

0 Likes
Message 5 of 15

nestly2
Mentor
Mentor

damian.wrobel wrote:
I don't know why my post which is shown above doesn't have new paragraphs, although when I wrote this post, I made the new paragraphs. And I add a .txt file which shows in which way I wrote my post.

 

Your browser or your IT may be blocking a necessary script (javascript) Enable script permissions for Lithium.com and/or addthis.com

 

0 Likes
Message 6 of 15

Anonymous
Not applicable
Thank you both for answers and help. You are great.
0 Likes
Message 7 of 15

Anonymous
Not applicable
And, by the way, how can I edit my post on this forum?
0 Likes
Message 8 of 15

nestly2
Mentor
Mentor

damian.wrobel wrote:
And, by the way, how can I edit my post on this forum?

 

At the top right in your reply, you should find the word "Options" with an arrow next to it. However, "edit post" will only be there for 30 minutes (or until someone replies to that message), after that, editing is not possible.  * the availability of "Options" is also dependent on the scripts previously mentioned.

0 Likes
Message 9 of 15

Anonymous
Not applicable
Hm... I still don't have solution of this problem. I understand, that HPANG is an angle in radians, not in degrees, and that is why HPANG is loaded as 0.767945 instead of 44. So I need the function which converts radians to degrees, not degrees to radians. I am right? So I wrote this function (defun Radians->Degrees (numberOfRadians) (* 180.0 (/ numberOfRadians pi)) And I set this function in lisp: ; RADTODEG = RADians TO DEGrees (DEFUN C:HNGINFRADTODEG (/ Radians->Degrees) (defun Radians->Degrees (numberOfRadians) (* 180.0 (/ numberOfRadians pi)) ) (setvar CurHANG (Radians->Degrees (getvar "HPANG"))) (princ "\nBieżący HatchAngle: ") (getvar CurHANG) ) ; CURHANG = CURrent Hatch ANGle But, in CommandLine there's an information about error: Command: HNGINFRADTODEG ; error: bad argument type: (or stringp symbolp): nil What is wrong? Why it doesn't work? Could you insert the entire code for properly working lisp?
0 Likes
Message 10 of 15

Ajilal.Vijayan
Advisor
Advisor

@Anonymous wrote:
 (setvar CurHANG (Radians->Degrees (getvar "HPANG"))) (princ "\nBieżący HatchAngle: ") (getvar CurHANG) ) ; CURHANG = CURrent Hatch ANGle But, in CommandLine there's an information about error: Command: HNGINFRADTODEG ; error: bad argument type: (or stringp symbolp): nil What is wrong? Why it doesn't work? Could you insert the entire code for properly working lisp?

Hi,

I dont think we can set user defined system variables, you may use getenv/setenv to define the user settings.

I think the error due to the use of  setvar to an unknown variable to AutoCAD.

 

Any luck to attach the lisp file or insert the code using the code tags to this forum ?

 

 

0 Likes
Message 11 of 15

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:
....  (setvar CurHANG (Radians->Degrees (getvar "HPANG"))) (princ "\nBieżący HatchAngle: ") (getvar CurHANG) ) ....


The (setvar) and (getvar) functions operate on AutoCAD System Variables only.  CurHANG is not a System Variable, but a user-defined variable.  Use (setq CurHANG) as in your first post, rather than (setvar...), to save a value into it, and just CurHANG to retrieve its value, rather than (getvar CurHANG).

Kent Cooper, AIA
0 Likes
Message 12 of 15

Anonymous
Not applicable
No 😞 When I click on "Options", no menu is shown; just the page is scrolling up to the top of itself, and on the end of the Internet address appears additional "#". And I know nothing about the code tags. I want to listen something like FAQ site for this forum or something like Help, where I could listen about how can I write posts on this forum. But there is nothing shown on this forum; neither in the menu on the top of the page nor in the right side of the page. And when I click on "Browse" and choose the attachment from the hard disc, I click then on "Add Attachment" and nothing happenes. I visited the pages Lithium.com and addthis.com, but what should I do after entering them? Looks like my computer don't want to cooperate.
0 Likes
Message 13 of 15

Anonymous
Not applicable
No 😞 When I click on "Options", no menu is shown; just the page is scrolling up to the top of itself, and on the end of the Internet address appears additional "#". And I know nothing about the code tags. I want to listen something like FAQ site for this forum or something like Help, where I could listen about how can I write posts on this forum. But there is nothing shown on this forum; neither in the menu on the top of the page nor in the right side of the page. And when I click on "Browse" and choose the attachment from the hard disc, I click then on "Add Attachment" and nothing happenes. I visited the pages Lithium.com and addthis.com, but what should I do after entering them? Looks like my computer don't want to cooperate.
0 Likes
Message 14 of 15

Anonymous
Not applicable
Thank you, Kent1Cooper! I corrected my lisps. Here they are: (DEFUN C:HSCNG (/ CurHSC CurHANG) (setq CurHSC (getreal "\nSet Current HatchScale for: ")) (setq CurHANG (getreal "\nSet Current HatchAngle for: ")) (COMMAND "HPSCALE" CurHSC ) (COMMAND "HPANG" CurHANG) ) ; ---- (DEFUN C:HSCNGDEF (/) (princ "\nSet current HatchScale for 1, and current HatchAngle for 0") (COMMAND "HPSCALE" "1") (COMMAND "HPANG" "0") ) ; ----------- (DEFUN C:HSCCNGG (/) (princ "\nChoose HatchPatterns to change HatchScale for HatchScale you setted") (princ "\nand to change HatchAngle for HatchAngle you setted: ") (setq zbior (ssget)) (COMMAND "_-HATCHEDIT" zbior "Properties" "") ) ; ---- (DEFUN C:HSCCNGG1 (/ HSC HANG) (setq HSC (getreal "\nEnter value for HatchScale: ")) (setq HANG (getreal "\nEnter value for HatchAngle: ")) (princ "\nChoose HatchPatterns to change HatchScale for HatchScale you setted") (princ "\nand to change HatchAngle for HatchAngle you setted: ") (setq zbior (ssget)) (COMMAND "_-HATCHEDIT" zbior "Properties" "" HSC HANG ) ) ; ---- ; DEF = DEFault (DEFUN C:HSCCNGGDEF (/) (princ "\nChoose HatchPatterns to change HatchScale for 1") (princ "\nand to change HatchScale for 0") (setq zbior (ssget)) (COMMAND "_-HATCHEDIT" zbior "Properties" "" "1" "0" ) ) ; ---- (DEFUN C:HSCCNGGCUR (/ Radians->Degrees CurHSC CurHANG) ;;;; ; Default, Autocad works on HatchAngle in Radians. ; In purpose to tell to Autocad, that it should give me HatchAngle in Degrees, ; not in Radians, this "Radians->Degrees" function is needed; (defun Radians->Degrees (numberOfRadians) (* 180.0 (/ numberOfRadians pi)) ) (setq CurHANG (Radians->Degrees (getvar "HPANG"))) ; CurHANG = Current Hatch ANGle ;;;; (setq CurHSC (getvar "HPSCALE")) ; CurHSC = Current Hatch SCale (setq zbior (ssget)) (princ "\nSelect Hatch Patterns to change their HatchScale for the Current HatchScale") (princ "\nand to change their HatchAngle for the Current HatchAngle: ") ; (princ "\nWybierz Hatch'e do zmiany HatchScale na bieżącą") ; (princ "\noraz do zmiany HatchAngle na bieżący: ") (COMMAND "_-HATCHEDIT" zbior "Properties" "" CurHSC CurHANG) ) ;----------- (DEFUN C:HNGGCUR (/ Radians->Degrees CurHANG) ;;;; ; Default, Autocad works on HatchAngle in Radians. ; In purpose to tell to Autocad, that it should give me HatchAngle in Degrees, ; not in Radians, this "Radians->Degrees" function is needed; (defun Radians->Degrees (numberOfRadians) (* 180.0 (/ numberOfRadians pi)) ) (setq CurHANG (Radians->Degrees (getvar "HPANG"))) ;;;; (setq zbior (ssget)) (princ "\nSelect Hatch Patterns to change their HatchAngle for the Current HatchAngle: ") (COMMAND "_-HATCHEDIT" zbior "Properties" "" "" CurHANG) ) ;----------- (DEFUN C:HSCINF (/) (princ "\nCurrent HatchScale is equal to: ") (getvar "HPSCALE") ) ;----- ;Działa ; RADTODEG = RADians TO DEGrees ; HNGINFRADTODEG (DEFUN C:HNGINF (/ Radians->Degrees CurHANG) ;;;; ; Default, Autocad works on HatchAngle in Radians. ; In purpose to tell to Autocad, that it should give me HatchAngle in Degrees, ; not in Radians, this "Radians->Degrees" function is needed; (defun Radians->Degrees (numberOfRadians) (* 180.0 (/ numberOfRadians pi)) ) (setq CurHANG (Radians->Degrees (getvar "HPANG"))) ;;;; (princ "\nCurrent HatchAngle is equal to: ") CurHANG ) ; CURHANG = CURrent Hatch ANGle ; ----
0 Likes
Message 15 of 15

Anonymous
Not applicable

Now I use Google Chrome and when I click on "Options", the menu is shown 🙂

Before I used Mozilla Firefox and probably it has an error.

 

There are my lisps from previous post.

 

(DEFUN C:HSCNG (/ CurHSC CurHANG)
 (setq CurHSC (getreal "\nSet Current HatchScale for: "))
 (setq CurHANG (getreal "\nSet Current HatchAngle for: "))
 (COMMAND "HPSCALE" CurHSC )
 (COMMAND "HPANG" CurHANG)
)

; ----

(DEFUN C:HSCNGDEF (/)
 (princ "\nSet current HatchScale for 1, and current HatchAngle for 0")
 (COMMAND "HPSCALE" "1")
 (COMMAND "HPANG" "0")
)

; -----------

(DEFUN C:HSCCNGG (/)
 (princ "\nChoose HatchPatterns to change HatchScale for HatchScale you setted")
 (princ "\nand to change HatchAngle for HatchAngle you setted: ")
 (setq zbior (ssget))
 (COMMAND "_-HATCHEDIT" zbior "Properties" "")
)

; ----

(DEFUN C:HSCCNGG1 (/ HSC HANG)
 (setq HSC (getreal "\nEnter value for HatchScale: "))
 (setq HANG (getreal "\nEnter value for HatchAngle: "))
 (princ "\nChoose HatchPatterns to change HatchScale for HatchScale you setted")
 (princ "\nand to change HatchAngle for HatchAngle you setted: ")
 (setq zbior (ssget))
 (COMMAND "_-HATCHEDIT" zbior "Properties" "" HSC HANG )
)

; ----

; DEF = DEFault
(DEFUN C:HSCCNGGDEF (/)
 (princ "\nChoose HatchPatterns to change HatchScale for 1")
 (princ "\nand to change HatchScale for 0")
 (setq zbior (ssget))
 (COMMAND "_-HATCHEDIT" zbior "Properties" "" "1" "0" )
)

; ----

(DEFUN C:HSCCNGGCUR (/ Radians->Degrees CurHSC CurHANG)

;;;;

; Default, Autocad works on HatchAngle in Radians.
; In purpose to tell to Autocad, that it should give me HatchAngle in Degrees,
; not in Radians, this "Radians->Degrees" function is needed;

 (defun Radians->Degrees (numberOfRadians)
 (* 180.0 (/ numberOfRadians pi))
 )

 (setq CurHANG (Radians->Degrees (getvar "HPANG"))) ; CurHANG = Current Hatch ANGle

;;;;

 (setq CurHSC (getvar "HPSCALE")) ; CurHSC = Current Hatch SCale
 (setq zbior (ssget))

 (princ "\nSelect Hatch Patterns to change their HatchScale for the Current HatchScale")
 (princ "\nand to change their HatchAngle for the Current HatchAngle: ")

; (princ "\nWybierz Hatch'e do zmiany HatchScale na bieżącą")
; (princ "\noraz do zmiany HatchAngle na bieżący: ")

 (COMMAND "_-HATCHEDIT" zbior "Properties" "" CurHSC CurHANG)
)

;-----------

(DEFUN C:HNGGCUR (/ Radians->Degrees CurHANG)

;;;;

; Default, Autocad works on HatchAngle in Radians.
; In purpose to tell to Autocad, that it should give me HatchAngle in Degrees,
; not in Radians, this "Radians->Degrees" function is needed;

 (defun Radians->Degrees (numberOfRadians)
 (* 180.0 (/ numberOfRadians pi))
 )

 (setq CurHANG (Radians->Degrees (getvar "HPANG")))

;;;;

 (setq zbior (ssget))
 (princ "\nSelect Hatch Patterns to change their HatchAngle for the Current HatchAngle: ")
 (COMMAND "_-HATCHEDIT" zbior "Properties" "" "" CurHANG)
)

;-----------

(DEFUN C:HSCINF (/)
 (princ "\nCurrent HatchScale is equal to: ")
 (getvar "HPSCALE")
)

;-----

;Działa
; RADTODEG = RADians TO DEGrees
; HNGINFRADTODEG

(DEFUN C:HNGINF (/ Radians->Degrees CurHANG)

;;;;

; Default, Autocad works on HatchAngle in Radians.
; In purpose to tell to Autocad, that it should give me HatchAngle in Degrees,
; not in Radians, this "Radians->Degrees" function is needed;

 (defun Radians->Degrees (numberOfRadians)
 (* 180.0 (/ numberOfRadians pi))
 )

 (setq CurHANG (Radians->Degrees (getvar "HPANG")))

;;;;

 (princ "\nCurrent HatchAngle is equal to: ")
 CurHANG
)
; CURHANG = CURrent Hatch ANGle

; ----

 

Thank you all for help.

0 Likes