Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Orient "north" block

6 REPLIES 6
Reply
Message 1 of 7
richie_hodgson
343 Views, 6 Replies

Orient "north" block

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

Richie
6 REPLIES 6
Message 2 of 7
devitg
in reply to: richie_hodgson

 

(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 

Message 3 of 7
Rtogores
in reply to: richie_hodgson

Why don't you just rotate and if necessary translate the existing insert?

Message 4 of 7

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.

Kent Cooper, AIA
Message 5 of 7

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.

Richie
Message 6 of 7
devitg
in reply to: richie_hodgson

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.

 

 

 

Message 7 of 7
richie_hodgson
in reply to: devitg

Absolutely no problem at all, solution found, problem solved. Thanks for helping

Richie

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost