Jump to content

Search the Community

Showing results for tags 'defun'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


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

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...

Found 4 results

  1. Hi all, I have a program to create circles from one point. It basically helps to draw a survey from running dimensions by entering all those and this spits circles out to those dims. There's a defun I got to create and update layers. The only thing I've added to that is adding a layer description. Here's where I get the defun (It's from @ronjonp ). It this some sort of localisation issue? Anyway, here's my full program below. PROBLEM: If I change the layer properties (color, linetype or description) the defun doesn't update them when I run my program. (vl-load-com) (defun c:--LDSurvey_Circles ( / ) (progn (LOAD "3dwannab_Survey_Circles"))) ;; -----------------------=={ Survey_Circles }==-------------------------- ;; ----------------------------------------------------------------------- ;; AUTHOR & ADDITIONAL CODE ;; Author: 3dwannab, Copyright © 2022 ;; Credit to ronjonp for the function to create or update layers. ;; ABOUT / NOTES ;; - Creates a set of circles from one chosen point. ;; - Creates a named layer that is coloured, DASHED and doesn't plot with a ;; layer description. ;; - This is handy for when you are drawing a survey and you have the survey in ;; running dimensions. ;; - Can also be useful for drawing an inner and outer circle, like a Donut. ;; Which is unlike the AutoCAD command that creates a thick arced Polyline. ;; USAGE ;; - Fist prompt with ask for the location for all the circles. ;; - Then a prompt will show to enter each of the circles radius' separated by a ;; space. ;; - For example. Entering '100 200 555' will create 3 circles with those three ;; circles in the string. ;; FUNCTION SYNTAX ;; Short-cut CIRS ;; Long-cut Survey_Circles ;; VERSION DATE INFO ;; Version 1.0 26-08-2022 First written ;; TO DO LIST ;; - BUG - Where the layer exists and it changed. Running this program will not ;; update it. ;; ----------------------------------------------------------------------- ;; -----------------------=={ Survey_Circles }==-------------------------- (defun c:CIRS nil (c:Survey_Circles)) (defun c:Survey_Circles ( / *error* acDoc cirRadiuses cirRadiusesStr layName ptCircle r ) (defun *error* (errmsg) (and acDoc (vla-EndUndoMark acDoc)) (and errmsg (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " errmsg " >>\n")) ) (vla-StartUndoMark (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))) (princ) ) (princ "'CIRS' or 'Survey_Circles' command ran..\n") ;; Start the undo mark here (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc)) ;; Set up variables (setq ptCircle (getpoint "Pick a point for the survey circles : ")) (setq cirRadiusesStr (getstring T "Enter the radiuses here separated by spaces : ")) ;; Split the string into a list (setq cirRadiuses (splitStr cirRadiusesStr " " " ")) ;; Make a new layer that is green, DASHED and doesn't plot with description (setq layName "Survey Circles") (_addOrUpdateLayer layName 100 "DASHED" 0 "Temp layer for survey circles") ;; Loop the cirRadiuses variable (foreach r cirRadiuses (progn (entmake (list '(0 . "circle") (cons 8 layName) (cons 10 ptCircle) (cons 40 r) ) ) ) ) (vla-EndUndoMark acDoc) (*error* nil) (princ) ) (princ) ;; Help with splitting a string https://www.cadtutor.net/forum/topic/66221-how-to-split-a-string-by-character/?do=findComment&comment=543913 ;; str = Input String, d = Delimiter, s = Character to use as the splitter (defun splitStr ( str d s / ) (read (strcat "("(vl-string-translate d s str)")")) ) ;; Creates a new layer or updates an existing one if it exists. ;; Will attempt to load the linetype if found in the acad*.lin file and if the layer exists, it will update the properties. ;; Code by ronjonp, taken from: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-layer-with-true-color-in-lisp/m-p/7904814#M367339 ;; Usage: ;; (_addOrUpdateLayer "NewLayerName" '(69 69 69) "3Dash2" 1 "Description goes here") ;; (_addOrUpdateLayer "NewLayerName2" 169 "3Dash2" 0 "Description goes here") ;; NOTE: ;; The 0 or 1 in examples above is for plot on = 1 or plot off = 0. ;; Modified by 3dwannab on 2022.06.11 to add description to the function. (defun _addOrUpdateLayer (name color ltype plot desc / _loadlinetype _rgb _setLayDescription d e) ;; RJP - 04.03.2018 ;; Creates or updates a layer (defun _rgb (l) (+ (lsh (fix (car l)) 16) (lsh (fix (cadr l)) 8) (fix (caddr l)))) (defun _loadlinetype (linetype / lt out) (cond ((tblobjname "ltype" linetype) t) ((setq lt (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object)))) (setq out (vl-catch-all-apply 'vla-load (list lt linetype (findfile (if (= 0 (getvar 'measurement)) "acad.lin" "acadiso.lin" ) ) ) ) ) (not (vl-catch-all-error-p out)) ) ) ) ;; _setLayDescription added by 3dwannab on 2022.06.11 (defun _setLayDescription ( name desc / ) (setq layerobj (vla-add (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) name)) (vla-put-description layerobj desc) ) (setq d (apply 'append (list (if (setq e (tblobjname "layer" name)) (entget e '("*")) (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") '(70 . 0) ) ) (list (cons 2 name) (if (listp color) (cons 420 (_rgb color)) (cons 62 color) ) (cons 6 (if (_loadlinetype ltype) ltype "continuous" ) ) (cons 290 plot) ;; 1 = plottable 0 = not=plottable ) ) ) ) (if e (entmod d) (entmakex d) ) (if name (_setLayDescription name desc) ) ) (princ (strcat "\n3dwannab_Survey_Circles.lsp Loaded. Invoke by typing 'CIRS' or 'Survey_Circles'")) (princ) ;; (c:Survey_Circles) ;; Uncomment for quick testing only ;;----------------------------------------------------------------------;; ;; End of File ;; ;;----------------------------------------------------------------------;;
  2. Ajmal

    defun c:

    “AJMAL” is my function I need shortcut “AJ” So I will put “defun c:aj()” But I need shortcut also full also, how I will set the “defun” (“aj” and “ajmal” also)
  3. Here is my section of code that I need help on. The error VisualLISP is giving me is :Function Canceled. The builder doesn't complain, so my syntax is correct, but its just not working. I am making simple lines and changing the color to them using the "change" command with a function call. Can anyone please tell me what I am doing wrong?? Also just fyi in defun c:wellplace.. i just used the line (color po2) because i don't want to post the whole code in, everything else works fine, but breaks when it gets to that line. (defun color (col) (command "change" col "" "P" "C" "T" "255,0,0" "") ) (defun c:wellplace () (color po2) ;po2 is a "point number 2" that is calculated else in the code. ) Shouldn't it take the po2 which is a polar point, consisting of x,y,z coordinates and pass it along to the "color function"? I am doing this, because I need to do the "change" command a good 8 times, and i don't want 8 of duplicate lines of the same thing. Also if i go with not defining a function and just inputting the "change" command right into the body of my code, it works perfect, and replace 'col' with 'po2' so what gives?
  4. working with some old code that I'm not to familiar with, the original writter used a different defun methood that I don't understand. Example (defun f:SC_GETINSPTS ( I can't run the lisp unless I change the "f" to a "c". Why is this? how can I run it without changing the code?
  • Create New...