Jump to content

Search the Community

Showing results for tags 'lisp routine'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • CADTutor
    • News, Announcements & FAQ
    • Feedback
  • AutoCAD
    • AutoCAD Beginners' Area
    • AutoCAD 2D Drafting, Object Properties & Interface
    • AutoCAD Drawing Management & Output
    • AutoCAD 3D Modelling & Rendering
    • AutoCAD Vertical Products
    • AutoCAD LT
    • CAD Management
    • AutoCAD Bugs, Error Messages & Quirks
    • AutoCAD General
    • AutoCAD Blogs
  • AutoCAD Customization
    • The CUI, Hatches, Linetypes, Scripts & Macros
    • AutoLISP, Visual LISP & DCL
    • .NET, ObjectARX & VBA
    • Application Beta Testing
    • Application Archive
  • Other Autodesk Products
    • Autodesk 3ds Max
    • Autodesk Revit
    • Autodesk Inventor
    • Autodesk Software General
  • Other CAD Products
    • BricsCAD
    • SketchUp
    • Rhino
    • SolidWorks
    • MicroStation
    • Design Software
    • Catch All
  • Resources
    • Tutorials & Tips'n'Tricks
    • AutoCAD Museum
    • Blocks, Images, Models & Materials
    • Useful Links
  • Community
    • Introduce Yourself
    • Showcase
    • Work In Progress
    • Jobs & Training
    • Chat
    • Competitions

Categories

  • Programs and Scripts
  • 2D AutoCAD Blocks
  • 3D AutoCAD Blocks
  • Images
    • Backgrounds

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Found 5 results

  1. Hello. I am using an old acad.lsp file with custom modified commands. After years of using it without any problems, it suddenly stopped working. This happened on two different computers with different versions of autocad (17 and 18) and without any software or windows updates. AutoCAD prompted me to change "command" to "command-s" in the lisp file and it resumed working. The problem now is that whenever i open a .dwg file it keeps asking me if i want to save the file on c: drive. I would like this to stop. Does anybody know if this is a lisp file issue and how to solve it?
  2. I want to move text to the nearest block intersection point so i can build 3d models from text. Without this my text is not bang on the marker.
  3. Hello, I have a lengthy lisp routine that hasn't been updated in years. It is strictly for Custom Field Insertions and I do not remember how to edit it. I created a diesel expression for what I'm trying to do which is simply adding dashes to a filename and removing the last 4 characters for our DWG #'s in the CAD file. I've made a diesel expression included below but it is too long for using MacAttEdit so I'd like to add it to this lisp routine if someone can understand it. Or perhaps if someone knows how to make the Diesel Expression shorter as I am just a novice at this. Our current file name is (28 characters): AB12345AB1234ABCA123456789-1 The DWG # is (FIRST 24 characters plus 5 dashes, so 29 characters): AB-12345-AB1234-ABC-A12-12345 Diesel Expression (long I know): %<\AcDiesel $(substr,$(getvar,DWGNAME),1,2)-$(substr,$(getvar,DWGNAME),3,5)-$(substr,$(getvar,DWGNAME),8,6)-$(substr,$(getvar,DWGNAME),14,3)-$(substr,$(getvar,DWGNAME),17,3)-$(substr,$(getvar,DWGNAME),20,5)>% Lisp with custom insertions: (defun c:updatetitleblock ( / ;;local variables acadObject acadDocument dProps customPropertyName customPropertyNamecpchem revCustomPropertyName projectCustomPropertyName folderCustomPropertyName folderCustomPropertyName2 KeyCount KeyValue strDrawingName strRevNum strDrawingNameNoSpaces left20characters left21characters left22characters left23characters left24characters left25characters left26characters left27characters left28characters left2characters left18characters ) ;;sets the document properties (setq acadObject (vlax-get-acad-object) acadDocument (vla-get-ActiveDocument acadObject) dProps (vlax-get-Property acadDocument 'SummaryInfo) customPropertyName "DRAWING No. (from file name)" customPropertyNamecpchem "filename sans characters after penultimate dash" revCustomPropertyName "REV (from file name)" projectCustomPropertyName "PROJECT NO (from file name)" projectCustomPropertyName2 "file name before underscore" folderCustomPropertyName "last character of folder" folderCustomPropertyName2 "last 2 characters of folder" left20characters "filename (left 20 characters)" left21characters "filename (left 21 characters)" left22characters "filename (left 22 characters)" left23characters "filename (left 23 characters)" left24characters "filename (left 24 characters)" left25characters "filename (left 25 characters)" left26characters "filename (left 26 characters)" left27characters "filename (left 27 characters)" left28characters "filename (left 28 characters)" left2characters "filename (left 2 characters)" left18characters "filename (left 18 characters)" ) ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName customPropertyName) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps customPropertyName "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left20characters;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName left20characters) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps left20characters "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left21characters;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName left21characters) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps left21characters "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left22characters;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName left22characters) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps left22characters "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left23characters;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName left23characters) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps left23characters "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left24characters;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName left24characters) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps left24characters "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left25characters;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName left25characters) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps left25characters "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left26characters;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName left26characters) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps left26characters "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left27characters;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName left27characters) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps left27characters "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left28characters;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName left28characters) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps left28characters "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left2characters;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName left2characters) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps left2characters "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left18characters;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName left18characters) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps left18characters "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR CPchem;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName customPropertyNamecpchem) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps customPropertyNamecpchem "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR REV;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName revCustomPropertyName) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps revCustomPropertyName "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR folderLastDigit;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName folderCustomPropertyName) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps folderCustomPropertyName "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR project number;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName projectCustomPropertyName) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps projectCustomPropertyName "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR project number;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName projectCustomPropertyName2) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps projectCustomPropertyName2 "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR project number;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets a couple variables so that we can determine whether the property exists (setq KeyCount 0 KeyValue nil) ;;while KeyValue is blank and KeyCount is less than number of properties (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps))) ;;get info about that property (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue ) ;;if the property name matches the name we want, set KeyValue to it's value (if (= TempKeyName folderCustomPropertyName2) (setq KeyValue TempKeyValue) ) ;;increment KayCount (setq KeyCount (1+ KeyCount)) ) ;; ;;now we add the property if it wasn't there already (if (= KeyValue nil) (vla-addcustominfo dProps folderCustomPropertyName2 "REOPEN DRAWING TO UPDATE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sets strDrawingName as the name of the current drawing (setq strDrawingName (getvar "dwgname")) ;;resets strRevNum (setq strRevNum "") ;;makes strDrawingName uppercase (setq strDrawingName (strcase strDrawingName)) ;;if the drawing name ends in .DWG, take off the last 4 characters (if (= (substr strDrawingName (- (strlen strDrawingName) 3) (strlen strDrawingName)) ".DWG") (setq strDrawingName (substr strDrawingName 1 (- (strlen strDrawingName) 4))) (setq strDrawingName strDrawingName) ) ;;makes strDrawingNameNoSpaces (setq strDrawingNameNoSpaces strDrawingName) (while (/= strDrawingNameNoSpaces (vl-string-subst "" " " strDrawingNameNoSpaces)) (setq strDrawingNameNoSpaces (vl-string-subst "" " " strDrawingNameNoSpaces))) ;;makes all the set-length filenames (setq strleft20characters (substr strDrawingNameNoSpaces 1 20)) (setq strleft21characters (substr strDrawingNameNoSpaces 1 21)) (setq strleft22characters (substr strDrawingNameNoSpaces 1 22)) (setq strleft23characters (substr strDrawingNameNoSpaces 1 23)) (setq strleft24characters (substr strDrawingNameNoSpaces 1 24)) (setq strleft25characters (substr strDrawingNameNoSpaces 1 25)) (setq strleft26characters (substr strDrawingNameNoSpaces 1 26)) (setq strleft27characters (substr strDrawingNameNoSpaces 1 27)) (setq strleft28characters (substr strDrawingNameNoSpaces 1 28)) (setq strleft2characters (substr strDrawingNameNoSpaces 1 2)) (setq strleft18characters (substr strDrawingNameNoSpaces 1 18)) ;;makes strDrawingNamecpchem (setq strDrawingNamecpchem strDrawingNameNoSpaces) (if (= (substr strDrawingNamecpchem (- (strlen strDrawingNamecpchem) 1) 1) "-") (setq strDrawingNamecpchem (substr strDrawingNamecpchem 1 (- (strlen strDrawingNamecpchem) 2))) (if (= (substr strDrawingNamecpchem (- (strlen strDrawingNamecpchem) 2) 1) "-") (setq strDrawingNamecpchem (substr strDrawingNamecpchem 1 (- (strlen strDrawingNamecpchem) 3))) (if (= (substr strDrawingNamecpchem (- (strlen strDrawingNamecpchem) 3) 1) "-") (setq strDrawingNamecpchem (substr strDrawingNamecpchem 1 (- (strlen strDrawingNamecpchem) 4)))) ) ) (if (= (substr strDrawingNamecpchem (- (strlen strDrawingNamecpchem) 1) 1) "-") (setq strDrawingNamecpchem (substr strDrawingNamecpchem 1 (- (strlen strDrawingNamecpchem) 2))) (if (= (substr strDrawingNamecpchem (- (strlen strDrawingNamecpchem) 2) 1) "-") (setq strDrawingNamecpchem (substr strDrawingNamecpchem 1 (- (strlen strDrawingNamecpchem) 3))) (if (= (substr strDrawingNamecpchem (- (strlen strDrawingNamecpchem) 3) 1) "-") (setq strDrawingNamecpchem (substr strDrawingNamecpchem 1 (- (strlen strDrawingNamecpchem) 4)))) ) ) ;;does stuff to get rid of revision number (if (= nil (vl-string-search "REV" strDrawingName)) ;;unless there is no rev, in which get rid of trailing numbers ;;if the last three digits of DrawingNameNoSpaces has a dash or a period or an underscore (if (/= (substr strDrawingNameNoSpaces (- (strlen strDrawingNameNoSpaces) 2) 3) (vl-string-subst "" "." (vl-string-subst "" "_" (vl-string-subst "" "-" (substr strDrawingNameNoSpaces (- (strlen strDrawingNameNoSpaces) 2) 3))))) (while (/= "_" (substr strDrawingName (strlen strDrawingName) 1) "-" (substr strDrawingName (strlen strDrawingName) 1) ".") (setq strRevNum (strcat (substr strDrawingName (strlen strDrawingName) 1) strRevNum) strDrawingName (substr strDrawingName 1 (- (strlen strDrawingName) 1)) ) ) ;;otherwise, if the last four digits are a dash and 3 numbers (if (= (vl-string-right-trim "0123456789" (substr strDrawingNameNoSpaces (- (strlen strDrawingNameNoSpaces) 3) 4)) "-") (progn (setq strRevNum (substr strDrawingNameNoSpaces (- (strlen strDrawingNameNoSpaces) 2) 3) strDrawingName (substr strDrawingName 1 (- (strlen strDrawingName) 4)) ) ) ) ) ;;gets rid of everything past the REV (setq strRevNum (substr strDrawingName (+ 4 (vl-string-search "REV" strDrawingName)) (- (+ 1 (strlen strDrawingName)) (vl-string-search "REV" strDrawingName))) strDrawingName (substr strDrawingName 1 (vl-string-search "REV" strDrawingName))) ) ;;gets rid of trailing spaces and dashes (setq strDrawingName (vl-string-right-trim " -._(" strDrawingName)) (setq strRevNum (vl-string-right-trim " -._()" strRevNum)) ;;gets rid of #. or ##.from beginning of drawing name (if (or (= (substr strDrawingName 2 1) ".") (= (substr strDrawingName 3 1) ".")) ;;gets rid of opening digits (setq strDrawingName (vl-string-left-trim "0123456789" strDrawingName)) ;;otherwise do nothing (setq strDrawingName strDrawingName) ) ;;gets rid of leading spaces and dashes (setq strDrawingName (vl-string-left-trim " -._)" strDrawingName)) (setq strRevNum (vl-string-left-trim " -._()" strRevNum)) ;;gets rid of leading zeros from drawing rev (if (and (= (substr strRevNum 1 1) "0") (> (strlen strRevNum) 1)) (setq strRevNum (substr strRevNum 2 (- (strlen strRevNum) 1))) ) (if (and (= (substr strRevNum 1 1) "0") (> (strlen strRevNum) 1)) (setq strRevNum (substr strRevNum 2 (- (strlen strRevNum) 1))) ) (if (and (= (substr strRevNum 1 1) "0") (> (strlen strRevNum) 1)) (setq strRevNum (substr strRevNum 2 (- (strlen strRevNum) 1))) ) ;;sets the property to our formatted name (vla-SetCustomByKey dProps left20characters strleft20characters) (vla-SetCustomByKey dProps left21characters strleft21characters) (vla-SetCustomByKey dProps left22characters strleft22characters) (vla-SetCustomByKey dProps left23characters strleft23characters) (vla-SetCustomByKey dProps left24characters strleft24characters) (vla-SetCustomByKey dProps left25characters strleft25characters) (vla-SetCustomByKey dProps left26characters strleft26characters) (vla-SetCustomByKey dProps left27characters strleft27characters) (vla-SetCustomByKey dProps left28characters strleft28characters) (vla-SetCustomByKey dProps left2characters strleft2characters) (vla-SetCustomByKey dProps left18characters strleft18characters) (vla-SetCustomByKey dProps customPropertyNamecpchem strDrawingNamecpchem) (vla-SetCustomByKey dProps customPropertyName strDrawingName) (vla-SetCustomByKey dProps revCustomPropertyName strRevNum) (vla-SetCustomByKey dProps folderCustomPropertyName (substr(getvar "dwgprefix") (- (strlen (getvar "dwgprefix")) 1) 1)) (vla-SetCustomByKey dProps folderCustomPropertyName2 (substr(getvar "dwgprefix") (- (strlen (getvar "dwgprefix")) 2) 2)) (vla-SetCustomByKey dProps projectCustomPropertyName (vl-string-right-trim " -._()" (substr strDrawingName 1 10))) (vla-SetCustomByKey dProps projectCustomPropertyName2 (vl-string-right-trim " -._()" (substr strDrawingName 1 (vl-string-search "_" strDrawingName)))) ;;forces update (command "updatefield" "all" "") ) (vl-load-com) (c:updatetitleblock) (princ) Thanks for any assistance and if I figure it out somehow I will re-post here.
  4. Hello everyone I was wondering if there is a way or a lisp command that reduces vertices of curved polylines. When i say a "curved polyline" i mean a polyline that has two segments that are arcs with the same radius, and if i explode that polyline and join it again, those two or more segments/arcs, just become one. I have used that "pldiet" lisp before but it only works with straight segments.
  5. Hi I have written a Lisp routine (shown below) that measures the distance between two points, and applies a scale factor that is written within the lisp, and displays it within the command line. Although the lisp functions, it may not be the 'cleanest'. I was wondering if it was possible to add a function to the lisp that in addition to displaying the newly calculated distance, will display a bearing. ideally, the bearing displayed would be written in a Degrees Minutes Seconds format, and not directional bearings (Ex. N73°25'45"W would be displayed as 286°34'15"). In the language of the lisp I have written, from 'x1', North is 0°, and the angle is turned clockwise from north, to a line drawn between 'x1' and 'x2'. Any help would be great. If anyone has a lisp that already does this, or can amend my lisp to do it, that would be perfect. Thanks Ahmed ;Use this command to measure the distance between two points while applying a Combined Scale Factor ;Be sure to copy this lisp to your job folder, and set your CSF as required. Do not change CSF outside of job folder. ;Ahmed F. 2017 (defun c:DM () (setq TD 0) (setq x1 (getpoint "\nSelect First Point: ")) (setq x2 (getpoint x1 "\nSelect Second Point: ")) (prompt (strcat (rtos (distance x1 x2)) (rtos (setq TD (+ TD (/(distance x1 x2) 0.999848)))) ) ) (prompt (strcat "\nTotal Distance = " (rtos TD))) (princ) ) thanks again.
×
×
  • Create New...