Trying to create a lsp command that will rotate a general note label
we have one that rotates Points ie z1, z2, z3, z4 That rotates the point to the respective quadrant
That lisp is below
;;; point rotation quadrant 1 (defun c:Z1 (/ doc pt sourcept ss ss2) (setq rlang (- (* pi 0.25) (getvar "viewtwist"))) (vl-load-com) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark doc) (princ "\n....select Points to change: ") (if (setq ss (ssget '((0 . "AECC_COGO_POINT")))) (while (> (sslength ss) 0) (setq pt (vlax-ename->vla-object (ssname ss 0))) (vlax-put pt 'labelrotation rlang) (ssdel (ssname ss 0) ss) ) ) ) ) (vla-endundomark doc) (princ) )
If someone could help me that would be awesome.
I would like to have 4 lsp routines Like-- L1, L2, ,L3, L4
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
Solved by Jeff_M. Go to Solution.
Unfortunately the Rotation property is not exposed for the Note Label in the COM API. This can be done using .NET, however. Attached is a zip file with a small .NET dll. Be sure to Unblock the zip file after downloading by locating the file in File Explorer, rt. click, properties, General tab, Unblock near the bottom of the dialog. You can create as many small lisps to call it with whatever rotation angle you wish. Here the one for 45 degrees:
(defun c:N1 (/ rlang ) (setq rlang (- (* pi 0.25) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) )
Add a line similar to this to your acad.lsp file so the NoteLabelRotate lisp function will always be available:
(netload "c:\\LocationOfMyCustomFiles\\RotateNoteLabels.dll")
I added it like this
(defun S::Startup () (princ "Changing VARIABLES...") (setvar "FILEDIA" 1) (setvar "SAVETIME" 5) (setvar "SAVEFIDELITY" 1) (setvar "PEDITACCEPT" 1) (setvar "MAXSORT" 8000) (setvar "OSNAPZ" 1) (setvar "FACETRES" 10) (setvar "ISOLINES" 2047) (setvar "PDMODE" 2) (netload "T:\ACTION\RotateNoteLabels.dll") (command "VIEWRES" "Y" 20000) (command "UCSICON" "ON") (command "AUDITCTL" "0") (command "_-PLOTSTAMP" "_LOG" "_NO" "PLOT.LOG" "") )
but i am getting this when it loads
Command: Changing VARIABLES...Regenerating model.
; error: no function definition: NETLOAD
Command:
ok i tried changing the angle but it does not change the rotation
(defun c:N1 (/ rlang ) (setq rlang (- (* pi 0.25) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) )
Command: N1
Select NoteLabels to rotate -343°-23'-15" degrees: 1 found
Select NoteLabels to rotate -343°-23'-15" degrees:
(defun c:N1 (/ rlang ) (setq rlang (- (* pi 0.50) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) )
Command: (LOAD "T:/ACTION/n1.lsp") C:N1
Command: n1
Select NoteLabels to rotate -253°-23'-15" degrees: 1 found
Select NoteLabels to rotate -253°-23'-15" degrees:
but label stays at 000°00'00"
Sorry about the wrong directions for adding to the acad.lsp file. Netload is a command, so needs to be used like this:
(command ".Netload" "pathtothefile\\filename.dll")
As for not changing the rotation, it's working as expected here.
I just found where it doesn't work...when this:
(- (* pi 0.25) (getvar "viewtwist"))
returns a negative value, the API uses 0. Attached is a lightly modified version that ensures the value is positive which appears to work for all cases.
It is not loading when the drawing starts. Had to load it myself with netload.
.Netload Assembly file name: T:ACTIONRotateNoteLabels.dll Unable to load T:ACTIONRotateNoteLabels.dll assembly.
Command: (LOAD "T:/ACTION/n1.lsp") C:N1
Command: N1
; error: no function definition: NOTELABELROTATE
Command:
Command: N1 ; error: no function definition: NOTELABELROTATE
Command:
Command: NETLOAD
Command: N1
Select NoteLabels to rotate -118°-23'-15" degrees: 1 found
Select NoteLabels to rotate -118°-23'-15" degrees:
Command:
Command:
Command: (LOAD "T:/ACTION/n1.lsp") C:N1
Command: N1
Select NoteLabels to rotate -163°-23'-15" degrees: 1 found
Select NoteLabels to rotate -163°-23'-15" degrees:
Command:
Command:
The angle is still not changing
file i am using
I got it to autoload with registry
ok now i just need a little help with the lsp
n4 | n1
-----------
n3 | n2
need to rotate labels to quadrant angles n1= 45 degrees of the current view
n2= 135 degrees of the current view
n3= 225 degrees of the current view
n4= 315 degrees of the current view
(defun c:N1 (/ rlang ) (setq rlang (- (* pi 0.0) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) ) (defun c:N2 (/ rlang ) (setq rlang (- (* pi -0.25) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) ) (defun c:N3 (/ rlang ) (setq rlang (- (* pi -0.75) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) ) (defun c:N4 (/ rlang ) (setq rlang (- (* pi -1.25) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) )
Thanks for all your help on this.
This works for me:
(defun c:N1 (/ rlang ) (setq rlang (- (* pi 0.25) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) ) (defun c:N2 (/ rlang ) (setq rlang (- (* pi 0.75) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) ) (defun c:N3 (/ rlang ) (setq rlang (- (* pi 1.25) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) ) (defun c:N4 (/ rlang ) (setq rlang (- (* pi 1.75) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) )
they need to be at 45 to the current view in the drawing and they are direct up-right-down-left
n1=ne
n2=se
n3=sw
n4-nw
See screencast below
I don't want it to rotate the current label i want it to set a fixed angle based on the current view.
like this one does for points
;;; point rotation quadrant 1 (defun c:Z1 (/ doc pt sourcept ss ss2) (setq rlang (- (* pi 0.25) (getvar "viewtwist"))) (vl-load-com) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark doc) (princ "\n....select Points to change: ") (if (setq ss (ssget '((0 . "AECC_COGO_POINT")))) (while (> (sslength ss) 0) (setq pt (vlax-ename->vla-object (ssname ss 0))) (vlax-put pt 'labelrotation rlang) (ssdel (ssname ss 0) ss) ) ) ) ) (vla-endundomark doc) (princ) )
You can get this to work with NoteLabels having the 45 degrees already set in the style by creating new calling lisps at 90 degree increments:
(defun c:N1R (/ rlang ) (setq rlang (- (* pi 0.0) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) ) (defun c:N4R (/ rlang ) (setq rlang (- (* pi 0.5) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) ) (defun c:N3R (/ rlang ) (setq rlang (- (* pi 1.0) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) ) (defun c:N2R (/ rlang ) (setq rlang (- (* pi 1.5) (getvar "viewtwist"))) (NoteLabelRotate rlang) (princ) )
Can't find what you're looking for? Ask the community or share your knowledge.