Lock All Viewports ~ Lisp

It never fails! Every time I have to work on somebody else’s drawings, their viewports are never locked! I got tired of click every viewport and locking them manually, so I created this lisp!


(defun c:vpl (/ kw kval doc adoc lao cnt inc cvprt blk pw)
   (vl-load-com)
   (initget 1 "LOCK UNLOCK")
   (setq kw (getkword "\nLOCK or UNLOCK ALL VPORTS [LOCK/UNLOCK]: "))
   (setq kw (strcase kw))
      (if (= kw "LOCK")
      (setq kval :vlax-true)
      (if (= kw "UNLOCK")
      (setq kval :vlax-false)
	)
	)
(setq doc (vlax-get-object "AutoCad.Application")
adoc (vla-get-ActiveDocument doc)
lao (vla-get-Layouts adoc)
cnt (vla-get-Count lao)
inc 0
)
(repeat cnt
(setq cvprt (vla-Item lao inc)
inc (+ inc 1)
blk (vla-get-Block cvprt)
)
(vlax-for itm blk
(if
(vlax-property-available-p itm 'DisplayLocked)
(progn
(vla-put-DisplayLocked itm kval)
(vla-update itm)
)
)
)
)
(princ)
)

Mtext Background Mask ~ Lisp

I hope everyone had a great Christmas and New years!

If you ever use a background mask for your text, you know how many steps it takes to turn the back ground mask on. Well here is a lisp to make it a lot easier!

Color: 8
Border: 1.1


(defun c:mblank ( / js n dxf_ent)
(setq js (ssget '((0 . "MTEXT"))))
(cond
(js
(repeat (setq n (sslength js))
(setq dxf_ent (entget (ssname js (setq n (1- n)))))
(entmod (append dxf_ent '((90 . 1) (63 . 8) (45 . 1.1) (441 . 0))))
)
)
)
)

AutoLISP: Create a Roof Pitch Symbol

AutoCAD Tips

If you need to create a roof pitch symbol this routine will surely help.

Here’s how:

  • PS <enter> to start “Pitch Symbol”
  • Select a line that has the slope that you need to calculate
  • Specify the base length of the symbol. (This is the horizontal line of the triangle). this can be done by entering a value in the command line or by picking 2 points
  • Specify what side of the line you want the symbol to be placed on.
  • Move the symbol into place

Note that the symbol created is not a block, it is a group

 c:pitch_symbol  a b c f g h i j k l m n p oldosmode oldosmode  a  c  a b  c c 'or  '=  pi  pi  pi  pi  b b b b b PITCH_BASE PITCH_BASE  c  PITCH_BASE c PITCH_BASE PITCH_BASE c h  d
             e  b  a f  b a  e f  a

View original post 1,172 more words

AutoLISP: Polyline Direction preview

AutoCAD Tips

The simplicity of this routine is why I like it so much. You simply run the command and then select a polyline and it displays temporary arrows that show the direction of the polyline. Once you either zoom in or out, or even use RE [enter] for a REGEN, the temporary arrows will stop displaying.

All credit goes to Luis Esquival and RonJon from the.swamp.org for sharing and editing this routine.

Below – Various polylines have their directions shown

PolyLine Direction

As an extra bonus, this routine works on 3DPOLYLINEs. Even though the arrows aren’t exactly aligned, it is still nice to have a way to show the direction…

PolyLine Direction 3DPOLY

~enjoy

 getarcsegment cen r fromvertex p2  a1 a2 d fromvertex p2 a1  cen fromvertex
		 a2  cen p2 a1 a2 a1 a2  d  r  a2 a1 d  r  a2 a1 d  r  getbulgedata bulge fromvertex p2  dir theta beta radio dat bulge
	theta 

View original post 692 more words