View Full Version : Get rotation of a Hatch
Mr Cory
2008-03-04, 10:56 PM
Hi Everyone
Does anyone know why the rotation/angle of a hatch is displayed in the entity properties? I run...
(entget(car(entsel)))
And i can get all the properties i need apart from the rotation/angle.
Am i going about this the wrong way or...?
Cheers for any advice!
Hi Everyone
Does anyone know why the rotation/angle of a hatch is displayed in the entity properties? I run...
(entget(car(entsel)))
And i can get all the properties i need apart from the rotation/angle.
Am i going about this the wrong way or...?
Cheers for any advice!
Hi Cory,
Look at DXF code 52. It is returned in radians.
Mr Cory
2008-03-04, 11:27 PM
Hi Tim
So it does i should have clicked to that! How easy is it to find the value, store it, convert it to degrees and then use it later on in the code? Or should i use a workaround... change the units to radians and then changing it back at the end of the code?
Hi Tim
So it does i should have clicked to that! How easy is it to find the value, store it, convert it to degrees and then use it later on in the code? Or should i use a workaround... change the units to radians and then changing it back at the end of the code?
It's a pretty easy conversion:
Radians to degrees:
(defun rtd (a)
(* a (/ 180.0 pi))
)
Degrees to Radians:
(defun dtr (a)
(* pi (/ a 180.0))
)
It depends on what is required. What are you trying to do with it?
Mr Cory
2008-03-04, 11:45 PM
Basically the routine will be an 'add selected' for hatches...
select a hatch that you want to duplicate
select a boundary
done
My current one just puts in a default one then does matchproperties but it hangs up on large areas. So i wanted to try and set the hatch style etc before the hatch is created. I guess i could have just increased the scale of the default hatch but its more of a learning curve really.
So if i was to write it into my code it would be something like this?
(setq deg (* rad (/ 180.0 pi)))
rad being the value in radians found earlier in the lisp. (sorry i wouldnt have a clue if this is how you write it or not)
Basically the routine will be an 'add selected' for hatches...
select a hatch that you want to duplicate
select a boundary
done
My current one just puts in a default one then does matchproperties but it hangs up on large areas. So i wanted to try and set the hatch style etc before the hatch is created. I guess i could have just increased the scale of the default hatch but its more of a learning curve really.
So if i was to write it into my code it would be something like this?
(setq deg (* rad (/ 180.0 pi)))
rad being the value in radians found earlier in the lisp. (sorry i wouldnt have a clue if this is how you write it or not)
You'll be using (command "-hatch" "P" <rest of settings here> "S" <select object>...) to create the new hatch?
If so, and deg is setq'd like your have it ^^^^, you should be ok.
Or, if the function rtd is loaded, you could use (rtd rad) as the argument in the appropriate spot within the command.
Mr Cory
2008-03-05, 12:05 AM
(setq deg (* newhpangle (/ 180.0 pi)))
WOW that did work, i just took a stab in the dark at that one. Thanks Tim you have been a big help and thanks for your code, i'd be lost without it lol Cheers! :beer:
(setq deg (* newhpangle (/ 180.0 pi)))
WOW that did work, i just took a stab in the dark at that one. Thanks Tim you have been a big help and thanks for your code, i'd be lost without it lol Cheers! :beer:
No worries. Happy coding. :)
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.