Jump to content

Rotate Blocks - Azimuth


Sambuddy

Recommended Posts

Could someone take a look at this lisp and let me know how I can get true north based on the North Symbol attached to remember my last pick so I can enter values as angle once the true north is set - I am thinking something like Offset command that keeps last entry if it is at all possible. Attached is the north symbol I am using on my projects but to orient antenna blocks to say 40 degrees from true north, then I have to go through selection process instead of value entry each time.

Thanks

(defun c:test (/ ss p1 oan nan rot)
(princ "\n Select objects to Rotate: ")(terpri)
	(setq ss (ssget))
	(setq p1 (getpoint "\n Center Point of Rotation: "))(terpri)
		(setq oan (getangle "\n Existing Angle Direction to be Corrected: "))(terpri)
		(setq nan (getangle "\n New Angle Direction: "))(terpri)
  		(setq rot (/ (* (- nan oan) 180) pi))
(command "rotate" ss "" p1 rot)
(princ)
) ;End Defun

 

 

Edited by Sambuddy
Link to comment
Share on other sites

This is my most updated one: Still could not do (remembering rot value which is True North Azimuth) so I do not have to select everytime!

Please help

(defun c:test (/ ss p1 oan nan rot angval rot2)
(princ "\n Select objects to Rotate: ")(terpri)
	(setq ss (ssget))
	(setq p1 (getpoint "\n Center Point of Rotation: "))(terpri)
		(setq oan (getangle "\n Existing Angle Direction to be Corrected: "))(terpri)
		(setq nan (getangle "\n True North Direction: "))(terpri)
  			(setq rot (/ (* (- nan oan) 180) pi))
  			(Princ rot)
  		(setq angval (getreal "Enter New Azimuth Positive Value: "))(terpri)
		(setq rot2 (- rot angval))
(command "rotate" ss "" p1 rot2)
(princ)
) ;End Defun

 

Link to comment
Share on other sites

I just cannot seem to get the True North be remembered (like offset last entry value).

Anyone...?

ignoring the north and replacing it with any lines to show me the azimuth/ angle for true north is good now.

(defun c:test (/ ss p1 oan nan rot angval rot2 size)
(princ "\n Select objects to Rotate: ")(terpri)
	(setq ss (ssget))
	(setq p1 (getpoint "\n Center Point of Rotation: "))(terpri)
		(setq oan (getangle "\n Existing Angle Direction to be Corrected: "))(terpri)
(if (not (setq size (vlax-ldata-get "rtt2" "size")))
  (setq size (vlax-ldata-put "rtt2" "size" 0.0))
)
(setvar "cmdecho" 0)
(if (setq nan (getangle
	       (strcat "\n True North Direction <" (rtos size) ">: ")
	      )
    )
)  
 			(setq rot (/ (* (- nan oan) 180) pi))
  
		(setq angval (getreal "Enter New Azimuth Positive Value: "))(terpri)
		(setq rot2 (- rot angval))
(progn
    (vlax-ldata-put "rtt2" "size" nan)  
(command "rotate" ss "" p1 rot2)
(setvar "cmdecho" cmdecho)
(princ)
)  
) ;End Defun

 

Link to comment
Share on other sites

No I did not - I do not think if even I need the north block (just a line to give me a direction would do) - that part is  fine.

I am now having trouble with radian vs. degree. I can get it to show but the calculation is done in radian (I am messed up).

(defun c:test (/ ss p1 oan angval size sz rot rot2) 
	(setq ss (ssget))
	(princ "\n Select objects to Rotate: ")(terpri)
		(setq p1 (getpoint "\n Center Point of Rotation: "))(terpri)
			(setq oan (getangle "\n Existing Angle Direction to be Corrected: "))(terpri)  
				(setq angval (getreal "Enter New Azimuth Positive Value: "))(terpri)  
(if (not (setq size (vlax-ldata-get "test" "size")))
  (setq size (vlax-ldata-put "test" "size" 0.0))
)
(if (setq sz (getangle
	       (strcat "\nTrue North Direction <" (angtos size) ">: ")
	     )
    )
(progn
    (vlax-ldata-put "test" "size" sz)
;	(setq rot (/ (* (- size oan) 180) pi))
;	(setq rot2 (- rot angval))
(command "rotate" ss "" p1 rot2)
(princ)
 ) ;End if
 )
) ; End Defun

;angtos = show angle
;rtos = show radians

 

Link to comment
Share on other sites

I do not know any other way to have it do what I want.

The code above does show / remembers the true north but I have to re-enter the value again (even though it show it for me), otherwise returns nil.

for some strange reason I have to re-enter the correct value that I succeeded in displaying.

 

Could you please help BIGAL?

sarah paulson please GIF (GIF Image)

 

image.thumb.png.3dc66106d0f2e9ec8d262f14bee24f36.png

Link to comment
Share on other sites

I am not quite sure why you would need Grid North unless you are digging holes all over the globe.

magnetic north is not my concern anymore - because of the major shift the electromagnetic north we removed it from all of our projects.

You question as to how you would align (it would be through getangle function I believe). Since your defined Cartesian coordinate is always 0 both in radians and degrees from a horizontal line, getangle will determine the angular dimension in two forms I believe angtos and rtos. in my case would be size and sz functions.

 

was that your question?  

Link to comment
Share on other sites

I wanted it to remember my last selection - it has nothing to do with how and many ways I am getting it.

 

I already solved the problem - it is now gets and remembers the last angle with 

 

(vlax-ldata-get "x" "y")))
(vlax-ldata-put "x" "y" 0.0))

Link to comment
Share on other sites

5 hours ago, Sambuddy said:

I am not quite sure why you would need Grid North unless you are digging holes all over the globe.

magnetic north is not my concern anymore - because of the major shift the electromagnetic north we removed it from all of our projects.

You question as to how you would align (it would be through getangle function I believe). Since your defined Cartesian coordinate is always 0 both in radians and degrees from a horizontal line, getangle will determine the angular dimension in two forms I believe angtos and rtos. in my case would be size and sz functions.

 

was that your question?  

 

Your indicated North Point shows Grid North and part of your initial question was

 

Quote

Could someone take a look at this lisp and let me know how I can get true north based on the North Symbol

 

That is not possible unless you know

 

1. How your current drawing is aligned

 

2. What the actual angular variations are between Grid, Magnetic and True North at the location in the drawing, as this varies depending on it's latitude and longitude. Since you have a North  Arrow indicating Grid North it is simple to calculate the direction of True North.

 

 

Code to create a dictionary. This dictionary will only be available in the drawing in which it was created.

 

(vl-load-com)

(defun ....


;create dictionary if not created
(cond ( (not (dictsearch (namedobjdict) "test"))
        ;get the item(s) you want to store and store the values in variables

		(vlax-ldata-put "test" "MEANINGFUL DATA NAME1" variable_name1)
		(vlax-ldata-put "test" "MEANINGFUL DATA NAME2" variable_name2)
      )
      (t
        (setq variable_name1 (vlax-ldata-get "test" "MEANINGFUL DATA NAME1"))
        (setq variable_name2 (vlax-ldata-get "test" "MEANINGFUL DATA NAME2"))
      )
);end_cond

;;rest of program
................
);end_defun

  If you want something available across multiple drawings in a session google autolisp vl-bb-set and read about that and the related references

 

If you want something available across drawings and sessions a csv file would probably be the best option.

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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