Author Topic: Get the Distance  (Read 6675 times)

0 Members and 1 Guest are viewing this topic.

One Shot

  • Guest
Get the Distance
« on: September 21, 2005, 11:51:12 AM »
Can someone please create a lisp to place a Evacuation Distance Path. The routine should do the following. Use a Polyline, Pick Starting Point and a End Point. Place the Distance in the Attribute provided with the distance rounded to the nearest inch. The Attribute show alway read the same regardless of the direct. Please reference the attachment.  (Evacuation Route.dwg)



Please ref. the attachment for an example for the purpose of this lisp routine. I think that this will answer your questions concerning vertexs in the polyline.
(Evacuation Plan.dwg)
Please ask if you have anyother questions.

Brad

« Last Edit: September 22, 2005, 10:29:47 AM by One Shot »

One Shot

  • Guest
Re: Get the Distance
« Reply #1 on: September 22, 2005, 10:15:37 AM »
If you want me to save these dwgs down please let me know. 

Thank you

LE

  • Guest
Re: Get the Distance
« Reply #2 on: September 22, 2005, 10:19:52 AM »
Normally a request won't bring much help....

What code do you have so far?

One Shot

  • Guest
Re: Get the Distance
« Reply #3 on: September 22, 2005, 10:39:32 AM »
Normally a request won't bring much help....

What code do you have so far?

I know.  I was just trying to spark interest.

As to the code,  I have something from another forum and it is not working just right.  It works fine up until it asks to label the line.  The block attribute is inserted but the measurement does not enter the block attribute.  :-(

Here is the code

Code: [Select]
(defun C:EVACROUTE (/ *SYSVAR* *DOC* CIRC LABELPT PLIN PLIN2 PT1 PT2 PTLIST RTDIST SPACE)
  ;;; (C) Richard Lawrence
  ;;; Provided as is. No Warranty. Use at your own risk.
  ;;; Permission granted to modify to suit needs.
  ;;; Only system variables changed are listed under
  ;;; Save Settings
  ;;||||||||||||||||||||||||||||||||||
  ;; Error Handler                   
  ;; Function provided by others     
  ;;||||||||||||||||||||||||||||||||||
  (defun *ERROR* (MSG)
    (if (not
  (member
    MSG
    '("Function cancelled" "console break" "quit / exit abort")
  )
)
      (alert MSG)
    )
    (RESTORE_SYS)
    (command "_.undo" "end")
    (princ)
  )
  ;;||||||||||||||||||||||||||||||||||
  ;; Set and Save System Variables   
  ;; Function provided by others     
  ;;||||||||||||||||||||||||||||||||||
  (defun SAVE_SYS (SYSVAR)
    (setq *SYSVAR* '())   ; global var list of saved values
    (repeat (length SYSVAR)
      (setq *SYSVAR*
     (append *SYSVAR*
     (list (list (car SYSVAR) (getvar (car SYSVAR))))
     )
      )
      (setq SYSVAR (cdr SYSVAR))
    )
  )
  ;;||||||||||||||||||||||||||||||||||
  ;; Restore System Variables      
  ;; Function provided by others     
  ;;||||||||||||||||||||||||||||||||||
  (defun RESTORE_SYS ()
    (and (listp *SYSVAR*)
(repeat (length *SYSVAR*)
   (setvar (caar *SYSVAR*) (cadar *SYSVAR*))
   (setq *SYSVAR* (cdr *SYSVAR*))
)
    )
  )

  ;;||||||||||||||||||||||||||||||||||
  ;; Create Layer                     
  ;; Function provided by others     
  ;;||||||||||||||||||||||||||||||||||
  (defun MLAYC (LAYNAME COLOR)
    (if (= NIL (tblsearch "layer" LAYNAME))   ; check if LAYER exist
      (command "-layer" "m" LAYNAME "c" COLOR "" "")
  ;if not exist, create LAYER
      (progn
(command "-layer" "t" LAYNAME "")   ; Thaw LAYER
(command "-layer" "on" LAYNAME "")   ; Turn on LAYER
(command "-layer" "s" LAYNAME "")   ; Set LAYER CURRENT
      )
    )
  )

;;; utility to insert a linetype if not already in drawing
  (defun INSLTYPE (LTYPE LTFILE /)
    (if (not (tblsearch "ltype" LTYPE))
      (command "linetype" "l" LTYPE LTFILE "")
    ) ;_ end of if
  ) ;_ end of defun


  ;;__ Save Settings___
  (SAVE_SYS '("CMDECHO" "CLAYER" "OSMODE" "PLINEWID")
  )

  ;;__ Set Settings for Function __
  (setvar "CMDECHO" 0)
  (setvar "PLINEWID" 4.0)
  (command "_.UNDO" "BEgin")

  (setq LAYERNAME  "EVAC-ROUTE"
LAYERCOLOR "7"
LAYERLTYPE "HIDDEN"
PLINEWID   4.0 ;_ Inches
BLOCKNAME  "EVACUATION DISTANCE TAG"
  )
  (MLAYC LAYERNAME LAYERCOLOR)
  (if (not
(= "Continuous"
   (cdr (assoc 6 (setq TEMP (tblsearch "Layer" "EVAC-ROUTE"))))
)
      )
    (command "-layer" "ltype" "Continuous" LAYERNAME "")
  )
;;; insert block definition if not already in drawing
  (if (not (tblsearch "block" BLOCKNAME))
    (progn
      (if (findfile BLOCKNAME)
(command "-insert" BLOCKNAME NIL)
(progn
  (alert
    (strcat "Block: "
    BLOCKNAME
    " not found in search path.  Verify location and retry."
    )
  )
  (quit)
)
      )
    )
    (progn

      ;;||||||||||||||||||||||||||||||||||
      ;; Get current space               
      ;; Function provided by others     
      ;;||||||||||||||||||||||||||||||||||
      (vl-load-com)
      (setq *DOC* (vla-get-activedocument (vlax-get-acad-object)))
      (setq SPACE (if (= 1 (vla-get-activespace *DOC*))
    (vla-get-modelspace *DOC*)   ;we're in modelspace
    (if (= (vla-get-mspace *DOC*) :vlax-true)
      (vla-get-modelspace *DOC*)  ;we're in modelspace
  ;thru paperspace VPort
      (vla-get-paperspace *DOC*)  ;we're in paperspace
    )
  )
      )
      ;;||||||||||||||||||||||||||||||||||
      ;; End Get Current Space           
      ;;||||||||||||||||||||||||||||||||||

      (prompt "\nCreate Evacuation Route")
      (setq PT1    (getpoint "\nSpecify Beginning of Route: ")
    PTLIST (list (car PT1) (cadr PT1))
    PT2    (getpoint PT1 "\nSpecify next point: ")
    RTDIST 0.0
      )
      (while PT2
(setq RTDIST (+ RTDIST (distance PT2 PT1))
      PT1    PT2
      PTLIST (append PTLIST (list (car PT1) (cadr PT1)))
      PT2    (getpoint PT1 "\nSpecify next point: ")
)
      )
      (rtos RTDIST 4 4)

      (setq PLIN (vlax-invoke SPACE 'ADDLIGHTWEIGHTPOLYLINE PTLIST)
    PLIN (entlast)

      )

      (setvar "osmode" 512)
      (setq LABELPT (getpoint "\nSpecify label location: "))
      (setq CIRC (vlax-invoke SPACE 'ADDCIRCLE LABELPT 12.0)
    CIRC (entlast)
      )

      (command "zoom" "Object" CIRC "")
      (command "trim" CIRC "" LABELPT "")
      (setq PLIN2 (entget (entlast))
    PLIN  (entget PLIN)
      )
      (if (assoc 43 PLIN)
(setq PLIN (subst (cons 43 4.0) (assoc 43 PLIN) PLIN))
(setq PLIN (append PLIN (list (cons 43.0))))
      )
      (if (assoc 43 PLIN2)
(setq PLIN2 (subst (cons 43 4.0) (assoc 43 PLIN2) PLIN2))
(setq PLIN2 (append PLIN2 (list (cons 43.0))))
      )
      (entmod PLIN)
      (entmod PLIN2)

      (entdel CIRC)
      (command "-insert"
       BLOCKNAME
       LABELPT
       1
       1
       0
       (rtos RTDIST 4 0)
      )
      (command "zoom" "Previous")
      (INSLTYPE LAYERLTYPE "acad.lin")
      (command "-layer" "ltype" LAYERLTYPE LAYERNAME "")
    )
  ) ;_ end of if
  (command "_.UNDO" "End")
  (RESTORE_SYS)
  (princ)
)

Here is what it said when I wanted to label the line.

Command: evacroute
Create Evacuation Route
Specify Beginning of Route:
Specify next point:
Specify next point:
Specify next point:
Specify next point:
Specify label location: Unknown command "26'-10"". Press F1 for help.


How about just trying to insert a circle and just text for the measurement.


Thank you,

Brad

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Get the Distance
« Reply #4 on: September 22, 2005, 10:59:57 AM »
And here is the sister thread.

http://forums.augi.com/showthread.php?t=25860
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

LE

  • Guest
Re: Get the Distance
« Reply #5 on: September 22, 2005, 11:01:07 AM »
Make sure you have a block named: "EVACUATION DISTANCE TAG" and with one attribute

Then change the line that reads:

(setq PLIN (append PLIN (list (cons 43.0))))

to

(setq PLIN (append PLIN (list (cons 43 0))))


Load the code again and must work.

HTH


deegeecees

  • Guest
Re: Get the Distance
« Reply #6 on: September 22, 2005, 11:06:50 AM »
Rudimentary in about 5 min...

Code: [Select]
(defun c:evacdist ()
(setq pnt1 (getpoint "\nStart point:"))
(setq pnt2 (getpoint "\nEnd point"))
(setq whadist1 (command "dist" pnt1 pnt2))
(setq whadist2 (rtos(getvar "distance")))
(setq ent1 (ssget))
(setq ent2 (ssname ent1 0))
(setq ent3 (entget ent2))
(SETQ ent4
(WHILE (/= "ATTRIB"(CDR (ASSOC 0 ent3)))
(WHILE (/= "DIST." (CDR (ASSOC 2 ent3)))
(SETQ ent5 (ENTNEXT ent2))
(SETQ ent3 (ENTGET ent5))
)
)
)

(setq ent4
(subst(cons 1 whadist2)
(assoc 1 ent4)ent4))
(entmod ent4)
(command "regen")
)

Wasn't sure what you were looking for.  :|

One Shot

  • Guest
Re: Get the Distance
« Reply #7 on: September 22, 2005, 01:19:42 PM »
Make sure you have a block named: "EVACUATION DISTANCE TAG" and with one attribute

Then change the line that reads:

(setq PLIN (append PLIN (list (cons 43.0))))

to

(setq PLIN (append PLIN (list (cons 43 0))))


I did this and it is still not working properly.  The person from AUGI and I worked on it several times and it still will not work right.  The reason that I went here to theswamp was to get another point of view on how to create the end product.


Thank you,

Brad

Load the code again and must work.

HTH



deegeecees

  • Guest
Re: Get the Distance
« Reply #8 on: September 22, 2005, 01:43:01 PM »
Make sure you have a block named: "EVACUATION DISTANCE TAG" and with one attribute

Then change the line that reads:

(setq PLIN (append PLIN (list (cons 43.0))))

to

(setq PLIN (append PLIN (list (cons 43 0))))


I did this and it is still not working properly. The person from AUGI and I worked on it several times and it still will not work right. The reason that I went here to theswamp was to get another point of view on how to create the end product.


Thank you,

Brad

Load the code again and must work.

HTH



OH MY GOD, THE CODE ATE HIM!!!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Get the Distance
« Reply #9 on: September 22, 2005, 01:43:10 PM »
A couple of things.

This does not affect you but the command "zoom" "Object" does not work in ACAD2000
Not sure which version it was implemented.

Here is what may be causing your problem:
The -insert command does not prompt you for a value if the variable ATTREQ is set to 0
So you must set it to 1 before using the -insert command.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

One Shot

  • Guest
Re: Get the Distance
« Reply #10 on: September 22, 2005, 01:48:33 PM »
Make sure you have a block named: "EVACUATION DISTANCE TAG" and with one attribute

Then change the line that reads:

(setq PLIN (append PLIN (list (cons 43.0))))

to

(setq PLIN (append PLIN (list (cons 43 0))))

I did this and it is still not working properly. The person from AUGI and I worked on it several times and it still will not work right. The reason that I went here to theswamp was to get another point of view on how to create the end product.


Thank you,

Brad

Load the code again and must work.

HTH



OH MY GOD, THE CODE ATE HIM!!!



Sorry for not understand CODE!!! Not everyone is advanced as you are.

One Shot

  • Guest
Re: Get the Distance
« Reply #11 on: September 22, 2005, 01:50:57 PM »
A couple of things.

This does not affect you but the command "zoom" "Object" does not work in ACAD2000
Not sure which version it was implemented.

Here is what may be causing your problem:
The -insert command does not prompt you for a value if the variable ATTREQ is set to 0
So you must set it to 1 before using the -insert command.


Thank you CAB!  Your a wealth in knowledge!  By the way, how is everything going for you?

One Shot

  • Guest
Re: Get the Distance
« Reply #12 on: September 22, 2005, 01:55:52 PM »
Okay CAB.  I changed the ATTREQ to 1 and the attribute edit dialog box came up.  But the distance will not insert into the attribute.

LE

  • Guest
Re: Get the Distance
« Reply #13 on: September 22, 2005, 02:00:24 PM »
ATTDIA = 0

deegeecees

  • Guest
Re: Get the Distance
« Reply #14 on: September 22, 2005, 02:02:22 PM »
Make sure you have a block named: "EVACUATION DISTANCE TAG" and with one attribute

Then change the line that reads:

(setq PLIN (append PLIN (list (cons 43.0))))

to

(setq PLIN (append PLIN (list (cons 43 0))))

I did this and it is still not working properly. The person from AUGI and I worked on it several times and it still will not work right. The reason that I went here to theswamp was to get another point of view on how to create the end product.


Thank you,

Brad

Load the code again and must work.

HTH



OH MY GOD, THE CODE ATE HIM!!!



Sorry for not understand CODE!!! Not everyone is advanced as you are.

Thats OK, you don't have to apologize, I was just kidding. If anything I should be apologizing toy you. See, now I'm in the belly of the beast.  :lol: