Hi I am trying to insert a norht block oriented on two selected points with the following
(defun c:North ( / ss )
;Orientate North Symbol
(setq oldos (getvar "osmode"))
(setq blk (vlax-ename->vla-object (car (entsel "\nChoose Object:"))))
(setq xy (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint blk))))
;errase block here
(setvar "osmode" 1)
(setq rot (getangle "\nPlease Select End Points :"))
(setq rot (* pt2 (/ 180 pi)))
(setq rot (- 360 pt2))
(setvar "osmode" 0)
(command "insert" "North" xy "0.75" "0.75" rot ""); insert north block in its place
(setvar "osmode" oldos)
)
I am not sure how to (a) errase the selected north block, then (b) make the insert north block in its place bit work
(defun c:North ( / ) (setq oldos (getvar "osmode")) (setq blk (car (entsel "\nChoose Object:"))) (setq xy (cdr (assoc 10 (entget blk)))) (setvar "osmode" 1) (setq rot (getangle xy "\nPlease Select End Points :")) (setq rot (* rot (/ 180 pi))) (setq rot (- 360 rot)) ;errase block here (command "_erase" blk "") (setvar "osmode" 0) (command "insert" "North" xy "0.75" "0.75" rot ""); insert north block in its place (setvar "osmode" oldos) )
Try it , simple LISP
Why don't you just rotate and if necessary translate the existing insert?
If you're putting it in the same place, you can just replace its block name and scales, and rotation if necessary:
(vl-load-com)
(setq blk (vlax-ename->vla-object (car (entsel "\nChoose Object: "))))
(setq rot (getangle "\nPlease Select End Points: ")); [ if necessary]
(vla-put-Name blk "North")
(vla-put-XScaleFactor blk 0.75)
(vla-put-YScaleFactor blk 0.75)
(vla-put-Rotation blk rot); [if necessary]
No need to convert the rotation angle to degrees, nor to involve an Insert command nor therefore to deal with object snap modes.
But if the idea is to replace some unwanted North Arrow block with the right one at the right size, and the wrong one is already aimed in the right direction, then there's also no need for the 'rot' variable -- it will keep its current rotation.
Hi Kent and Devig
Kents code worked a treat, the object was to select the orientation of the north symbol based on linework someware else on the drawing, On my PC Devig's code put the insert of the north block as the first point of the getangle code which wasn't what I wanted, not sure why it was doing this.
Just guessing what you want to do .
I can not see where the PT2 comes from .
It happen because I can not see the DWG .
It is my fault.
Absolutely no problem at all, solution found, problem solved. Thanks for helping