Jump to content

Rotating in segments


TunzaGibbo

Recommended Posts

Hi All

 

Is it possible in Autolisp to insert a block (In this case it's a line) then pick a point (this point defines the centre of an imaginary circle) once the point is picked I would like to move the cursor 360 deg around the point. Like drawing the imaginary point but as the cursor moves through the imaginary 8/45 deg segments the block (Line) will rotate as the cursor moves through each segment. So as the cursor moves around the centre point the line will rotate 8 times (45 deg for each segment. Once I decide the required rotation i would then click the mouse to accept.

I hope you can understand all that

 

Regards :)

Link to comment
Share on other sites

Hi All

 

Is it possible in Autolisp to insert a block (In this case it's a line) then pick a point (this point defines the centre of an imaginary circle) once the point is picked I would like to move the cursor 360 deg around the point. Like drawing the imaginary point but as the cursor moves through the imaginary 8/45 deg segments the block (Line) will rotate as the cursor moves through each segment. So as the cursor moves around the centre point the line will rotate 8 times (45 deg for each segment. Once I decide the required rotation i would then click the mouse to accept.

I hope you can understand all that

 

Regards :)

 

 

Sounds like you need (grread) although i'm not certain it will do what you want in the order you want it.

 

 

Demo code to draw a line per to a curve

;;; Draw perpendicular line
;;; Alan J. Thompson, 10.15.09
(defun c:LPer (/ #Ent #Read)
 (and
   (setq #Ent (car (entsel "\nSelect curve: ")))
   (vl-position (cdr (assoc 0 (entget #Ent))) '("LWPOLYLINE" "ARC" "LINE" "CIRCLE" "ELLIPSE"))
   (while (not (eq 25 (car (setq #Read (grread T 15 0)))))
     (princ "\rSpecify point for line: ")
     (redraw)
     (if (vl-consp (cadr #Read))
       (grdraw (vlax-curve-getclosestpointto #Ent (trans (cadr #Read) 1 0) T)
               (trans (cadr #Read) 1 0)
               1
       ) ;_ grdraw
     ) ;_ if
     (if (eq 3 (car #Read))
       (entmake (list '(0 . "LINE")
                      (cons 10 (vlax-curve-getclosestpointto #Ent (trans (cadr #Read) 1 0) T))
                      (cons 11 (trans (cadr #Read) 1 0))
                ) ;_ list
       ) ;_ entmake
     ) ;_ if
   ) ;_ while
 ) ;_ and
 (redraw)
 (princ)
) ;_ defun

Draw any arc, circle, ellipse or polyline, load the lisp then type "lper". Move the cursor around. The red line is always per to selected object. If you left click it will draw a line from the point clicked per to the selected object.

 

 

Or my dynamic Angle and Distance

 

(defun c:DAD (/  pt pos dms)
 (and (setq pt (getpoint "\nSpecify base point: "))
   (while (eq 5 (car (setq pos (grread T 15 0))))
     (redraw)
     (grdraw pt (cadr pos) 1 1)
     (setq dms (strcat "Angle : " (angtos (angle pt (cadr pos)) 1 4) "   Distance : " (rtos (distance pt (cadr pos)) 2 3)))
     (princ (strcat "\r" dms "       "))
     (grtext -1 dms)
   );end_while
 );end_and
 (redraw)
 (princ)
);end_defun

 

 

Angle is displayed in Degrees minutes and seconds but its easy to change

Edited by dlanorh
added code
Link to comment
Share on other sites

segment? 'polar snap' 45d?

(setq [b]a[/b] (angle p1 p2))
([color="blue"] polar[/color] p1 (- [b]a[/b] ([color="blue"][b]rem[/b][/color] [b]a[/b] (* 0.25 pi))) (distance p1 p2) )

 

or dynamic block?

Link to comment
Share on other sites

Why don't you use Polar Tracking? https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-Core/files/GUID-7EC3C63D-EA4E-4E65-A676-C3A3627E3F19-htm.html

 

Just enable it, set the angle of rotation for 45, or whatever increment you want, then use the rotate command as you normally would. As you move your cursor around the base point it will snap to the angle you specified.

 

Also, when you insert a block, if you enable "specify rotation on screen", you can rotate the block around its insertion point using the polar tracking angle you specified.

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