Author Topic: turning off and on extension lines and ticks, need help  (Read 1933 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
turning off and on extension lines and ticks, need help
« on: May 16, 2005, 11:33:54 AM »
i have this bit off code to turn off and on extension lines but i would like it to also turn on and off ticks can someone point me in the right direction

Code: [Select]
;***************************** XTSWITCH.LSP ***********************************
;     Purpose:  Switches Extension Lines On and Off by Picking Geometry
;     Created:  7/24/97
;     Modified: 11/25/97  added error handler
;     Modified: 3/7/99 changed all globals to registered prefix tktn_
;     Author:  Herman Mayfarth
;              Tekton Construction Services
;              h_mayfarth@compuserve.com
;     Copyright (c) 1997,1999 by Herman Mayfarth
;     Permission granted to freely use and redistribute without fee.
;     Provided "as is". No warranty express or implied.
;
;******************************************************************************
;; error handler
(defun tktn_serr(msg)
    (tktn_exitsw)
    (if
      (or
        (= msg "Function cancelled")
        (= msg "quit / exit abort")
      )
      (princ)
      (princ (strcat "\nError: msg"))
    );end if
    (princ)
);end tktn_serr
;;----------------------------------------------------------------------------
;; startup function
(defun tktn_strtsw()
    (command "_.UNDO" "BEGIN")
    (setq olderr *error*
          *error* tktn_serr)
    (setq oldecho (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (princ)
);end tktn_strtsw
;;---------------------------------------------------------------------------
;; exit function
(defun tktn_exitsw()
    (setvar "cmdecho" oldecho)
    (setq *error* olderr
          olderr nil)
    (command "_.UNDO" "END")
    (princ)
);end tktn_exitsw
;;---------------------------------------------------------------------------
;; basic switch function
(defun tktn_xtln_switch (val / s a e1 pt d1 d2 which switchval)
;; initialize variables
(setq s T)      
(setq which nil)
(setq switchval val)
;; get dimension to change
(while s
   (setq a (entsel "\nSelect Dimension Near Extension Line to Change:\n"))
   (setq pt (trans(cadr a) 1 0))
   (setq e1 (entget (car a)))
   (if (= "DIMENSION" (cdr(assoc 0 e1)))
   (setq s nil)
   );end if
);end while

;; evaluate distances to definition points
(setq d1 (distance pt (cdr(assoc 13 e1))))
(setq d2 (distance pt (cdr(assoc 14 e1))))

;; decide which extension line to toggle
(cond
   ((> d1 d2) (setq which "DIMSE2"));toggle DIMSE2
   ((> d2 d1) (setq which "DIMSE1"));toggle DIMSE1
   (T nil)
);end cond
;; do it!
(command "_.dimoverride" which  switchval "" (car a) "")
(princ)
);end tktn_xtln_switch
;;----------------------------------------------------------------------------
;; turn on line
(defun C:XTLON( / oldecho olderr)
   (tktn_strtsw)
   (tktn_xtln_switch 0)
   (tktn_exitsw)
   (princ)
);end XTLON
;;--------------------------------------------------------------------------
;; turn off line
(defun C:XTLOFF( / oldecho olderr)
   (tktn_strtsw)
   (tktn_xtln_switch 1)
   (command "_.REDRAW")
   (tktn_exitsw)
   (princ)
);end XTLOFF
;;-------------------------------------------------------------------------
;; load prompts
(princ "\nXTSWITCH loaded....")
(princ "\nXTLON turns on extension line,XTLOFF turns it off")
(princ)

daron

  • Guest
turning off and on extension lines and ticks, need help
« Reply #1 on: May 16, 2005, 11:38:59 AM »
For that one, you'll need to take the code there and instead of using dimse use dimblk1, dimblk2 and dimldrblk and set them to none. That's my take on it anyway.

pmvliet

  • Guest
turning off and on extension lines and ticks, need help
« Reply #2 on: May 16, 2005, 05:34:07 PM »
I had an old way of suppressing the extension lines which was
Code: [Select]
(defun c:s1  () (command "setvar" "dimse1" "on" "dim1" "update"))
(defun c:s2  () (command "setvar" "dimse2" "on" "dim1" "update"))
(defun c:s3  () (command "setvar" "dimse1" "off" "setvar" "dimse2" "off" "dim1" "update"))


I thought that instead of dimse1 & dimse2, we could replace dimblk1 and dimblk2. Would give you
Code: [Select]
(defun c:a1  () (command "setvar" "DIMBLK1" "None" "dim" "update"))
(defun c:a2  () (command "setvar" "DIMBLK2" "None" "dim" "update"))


But it doesn't work. if I run it on a dimension and list out the dimension, I t says that that has been set to none, but it still displays both arrowheads. it is treating it as a override though... which it should... But if I right-click, properties, it still shows both arrowheads...

So something is not taking...

Pieter

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
turning off and on extension lines and ticks, need help
« Reply #3 on: May 16, 2005, 05:44:28 PM »
I dont know how to do it in lisp, but here is what I have in VBA
Code: [Select]
Public Sub FixDimsL()

Dim objSelected As Object
Dim objSelSet As AcadSelectionSet
Dim N As Integer, intCode(0) As Integer
Dim strCode(0) As String, obj As AcadObject, objEnt As AcadEntity, objDim As AcadDimension
Dim dblPt1(2) As Double, objCenter As Variant
On Error Resume Next

If ThisDrawing.SelectionSets.Count > 0 Then
    For N = 0 To ThisDrawing.SelectionSets.Count - 1
        If ThisDrawing.SelectionSets.Item(N).Name = "FIXd" Then
        ThisDrawing.SelectionSets("FIXd").Delete
        End If
    Next N
End If
Set objSelSet = ThisDrawing.SelectionSets.Add("FIXd")
objSelSet.SelectOnScreen
    For Each obj In objSelSet
        If obj.ObjectName = "AcDbRotatedDimension" Then

        obj.ExtLine1Suppress = True
        End If
    Next obj
ThisDrawing.SelectionSets("FIXd").Delete
Exit Sub
End Sub

Public Sub FixDimsR()

Dim objSelected As Object
Dim objSelSet As AcadSelectionSet
Dim N As Integer
Dim obj As AcadObject
On Error Resume Next

If ThisDrawing.SelectionSets.Count > 0 Then
    For N = 0 To ThisDrawing.SelectionSets.Count - 1
        If ThisDrawing.SelectionSets.Item(N).Name = "FIXd" Then
        ThisDrawing.SelectionSets("FIXd").Delete
        End If
    Next N
End If
Set objSelSet = ThisDrawing.SelectionSets.Add("FIXd")
objSelSet.SelectOnScreen
    For Each obj In objSelSet
        If obj.ObjectName = "AcDbRotatedDimension" Then
       
        obj.ExtLine2Suppress = True
        End If
    Next obj
ThisDrawing.SelectionSets("FIXd").Delete
Exit Sub
End Sub

That would suppress for the dims you pick, not globally
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)