Skip to main content
Autodesk India Community logo
Login | Register
  • Home
  • Resources
  • Blog Roll
    • Autodesk Labs
    • Autodesk Videos
    • CAD Professor
    • Computer Graphics India
    • Inventor Certification
    • Inventor talks
    • Lynn Allen
    • Mastering CAD
    • Shaan Hurley
    • Small Guru
    • Subhendu 3D
    • What A Mesh
    • Mastering AutoCAD
  • Forums
    • Getting Started
    • AutoCAD General
    • AutoCAD Topic Specific
    • AutoCAD Customization
    • AutoCAD LT
    • Autodesk Inventor
    • Autodesk Revit
  • Social Media
    • Facebook
    • Twitter
  • Contact Us
    • Autodesk Communities
    • Community Contributors
  • Autodesk India
AutoCAD 2014

Learn more about AutoCAD 2014 and its features

Learn More
AutoCAD LT 2014

Learn more about AutoCAD LT 2014 and its features

Learn More
Autodesk Inventor 2014

Learn more about Autodesk Inventor 2014, new features 

Learn More
Autodesk Revit 2014

Learn more about Revit 2014

Learn More

AutoCAD Customization: Visual LISP, AutoLISP and General Customization

Syndicate content
Visual LISP, AutoLISP and General Customization topics
URL: http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/bd-p/130
Updated: 11 min 11 sec ago

Retrieving # of entities in a dynamic block ?

Sun, 2013-05-19 22:39

I am modifying stuff in a dynamic block insert entitity. There is no "endblk" entity at the end of these definitions and I need to cycle through every entity within the block definition. When it gets to the last entity,  I get an error because you cannot entnext passed the last entity. There are 2 things I could use help with:

 

1. How to retrieve the # of entities in a block without cycling through it.

 

Or

 

2. A quick lesson in the *error* function, I cannot figure out how to implement this. I basically want to to say:

(if (entnext myent)) returns a error, don't abort & continue on.

 

Is this possible ?

 

Thanks

Categories: AutoCAD Customization, Autodesk Forums

Where is the developer documentation in map 2014?

Sat, 2013-05-18 13:55

I've just downloaded autocad map 2014, but I can't find the developer documentation. I can find some crap in the general help referencing lisp and vba, but no clearly organized developer documentation. In the previous versions there used to be an acad_devxxx.chm  file, that was perfect for the job, but I can't find anything similar here. Do I really need to install an earlier version and copy the file from there?

 

Categories: AutoCAD Customization, Autodesk Forums

detect intersection of line and circle

Sat, 2013-05-18 05:18

how do you detect the intersection of a line and circle or arc

Categories: AutoCAD Customization, Autodesk Forums

Multileader Block Attributes

Sat, 2013-05-18 03:13

Entity name of  MULTILEADER they have 3 (assoc 10 ) the first (10 4.11 7.0 0.0) is end points to the tab by the dimenson the next one (10 3.75 7.0 0.0) is the other end point of the tab and the last one (10 2.75 6.0 0.0) is to where the arrow head is how do you have it get it pick the second and third 10 this will only pick the first one (setq pt1 (cdr (assoc 10 (entget (car ML))))) 

Categories: AutoCAD Customization, Autodesk Forums

turn on/off annotative

Sat, 2013-05-18 02:13

Hi Guys,

 

when a text is selected, in properties palette the Annotative field can be turned on/off  - how can i do it programatically?

 

activex doesn't not have a propertiy for it. i presume it is in xrecords but could not find it.

 

 

thanks in advanced

Moshe

 

 

Categories: AutoCAD Customization, Autodesk Forums

help needed

Fri, 2013-05-17 21:43

I prepared a simple code to make a char table.

It is very easy, but did not work!!

 

can anybody tell me what is the problem?

 

(Defun C:CharMap () (setq cnt 1) (setq r_cnt 0.0) (setq ts 16) ;;16x16=256 char (setq x 0.0 y 0.0 sub_y (- y 0.1)) (repeat ts (repeat ts (command "text" "j" "mc" (list x y) "0.05" "0" (chr cnt)) (command "text" "j" "mc" (list x sub_y) "0.05" "0" (itoa cnt )) (setq x (+ x 0.2)) (setq cnt (1+ cnt)) );repeat (setq x 0 y (- y 0.2)) (setq sub_y (- y 0.1)) );repeat (command "zoom" "e" "zoom" "0.75x") )

 Thanks,

Abbas

Categories: AutoCAD Customization, Autodesk Forums

Overlapping Dimension

Fri, 2013-05-17 21:36

Anybody have a suggestion to find overlapping dimensions ?

ie: Have a dimension of 2'-0" with a dimension beside of 3'-0" which is correct

BUT

A too quick drafter would have a dimension of 2'-0" and a dimension beside of 5'-0" beacuse the 2'-0" dimension is on top of the 5'-0" dimension. The 5'-0" dimension would be the overall distance of the 2'-0" + the 3'-0" dimension.

 

Both of the dimensions are correct but they are on top of each other.

 

 

Categories: AutoCAD Customization, Autodesk Forums

How to set the dimension break size in autolisp

Fri, 2013-05-17 21:02

I there any way to set the dimension break size in autolisp

Categories: AutoCAD Customization, Autodesk Forums

Maximum Number Of Lisp Files Compiled to a single VLX File

Fri, 2013-05-17 20:24

I just noticed that I can't put any more than 11 lisp files when trying to make one VLX file.

 

Does this sound true to anyone?

 

I wanted to break out all of our lisp commands to their own file, so that it is easier to track down and troubleshoot (I guess that's a matter of opinion).

 

If this is normal or expected behavior, is there anyother way that i accomplish what i'm trying to do?  I want a lot of lisp files, but i only wnat one file for users to load into their start-up suite or what have you.

 

Thanks

KP

Categories: AutoCAD Customization, Autodesk Forums

2014 and keyboard context menu key

Fri, 2013-05-17 18:41

switching from 2010 win xp to 2014 win 7

i need my specific user interface  , and cant replicate it because of this issue  :

 

i used to press context menu key on keybard to make edit menus pop up . 

 in 2014 even though its same settings  (show context menus and time sentive click)  i ve lost this ability .

 

either menus dont appear at all or they are replaced by the small command line context menu 

i think this suggest new command line features are messing with right click options

 

interested in suggestions about any variable i can turn off , or else to go back to normal 

 

 

Categories: AutoCAD Customization, Autodesk Forums

how can i change radius value in duct lisp

Fri, 2013-05-17 16:22
this is a duct lisp which is i found , could anybody tell me which code line i have to change and how for radius value ? for example if my . " Specify first segment width value " is 1500 then i wanna be my inside fillet radius 1500 / 3 thank you ---------------------------------------------------------------------------------------------------------------------------------------- (defun c:duct(/ actDoc Ang1 Ang2 ptLst enDist fPt lEnt lObj lPln oldVars oldWd plEnd plStart1 plStart2 prDir segLst Start stDist stLst tAng vlaPln *error*) (vl-load-com) (defun GetPlineVer(plObj) (mapcar 'cdr (vl-remove-if-not '(lambda(x)(=(car x)10)) (entget plObj))) ); end of GetPLineVer (defun asmi-PlineSegmentDataList(plObj / cLst outLst) (setq cLst (vl-remove-if-not '(lambda(x)(member(car x) '(10 40 41 42))) (entget plObj)) outLst '() ); end setq (while cLst (if(assoc 40 cLst) (progn (setq outLst (append outLst (list (list (cdr(assoc 10 cLst)) (cdr(assoc 40 cLst)) (cdr(assoc 41 cLst)) (cdr(assoc 42 cLst)) ); end list ); end list ); end if ); end setq (repeat 4 (setq cLst(cdr cLst)) ); end repeat ); end progn (setq outLst (append outLst (list (list (cdr(assoc 10 cLst)) ); end list ); end list ); end append cLst nil ); end setq ); end if ); end while outLst ); end of asmi-GetPlineSegmentData (defun asmi-LayersUnlock(/ restLst) (setq restLst '()) (vlax-for lay (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object))) (setq restLst (append restLst (list (list lay (vla-get-Lock lay) (vla-get-Freeze lay) ); end list ); end list ); end append ); end setq (vla-put-Lock lay :vlax-false) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Freeze(list lay :vlax-false))) t) ); end vlax-for restLst ); end of asmi-LayersUnlock (defun asmi-LayersStateRestore(StateList) (foreach lay StateList (vla-put-Lock(car lay)(cadr lay)) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Freeze(list(car lay)(nth 2 lay)))) t) ); end foreach (princ) ); end of asmi-LayersStateRestore (defun PipeMLineStyle(/ dxfLst mlDict) (setq dxfLst (list'(0 . "MLINESTYLE")'(102 . "{ACAD_REACTORS")'(102 . "}") '(100 . "AcDbMlineStyle") '(2 . "DUCT_PIPE") '(70 . 272)'(3 . "")'(62 . 256)'(51 . 1.5708)'(52 . 1.5708) '(71 . 2)'(49 . 0.5)'(62 . 256)'(6 . "BYBLOCK") '(49 . -0.5)'(62 . 256)'(6 . "BYBLOCK"))); end setq (if (null (member (assoc 2 dxfLst) (dictsearch (namedobjdict) "ACAD_MLINESTYLE"))) (progn (setq mlDict (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_MLINESTYLE")))) (dictadd mlDict (cdr(assoc 2 dxfLst))(entmakex dxfLst)) ); end progn ); end if ); end of PipeMLineStyle (defun *error*(msg) (setvar "CMDECHO" 0) (if lObj (command "_.erase"(entnext lObj)"") (command "_.erase"(entlast)"") ); end if (if oldVars (mapcar 'setvar '("FILLMODE" "PLINEWID" "CMDECHO" "OSMODE") oldVars); end mapcar ); end if (if stLst (asmi-LayersStateRestore stLst) ); end if (if actDoc (vla-EndUndoMark actDoc) ); end if (princ "*Cancel* ") (princ) ); end of *error* (PipeMLineStyle) (if(not dpipepWd)(setq dpipepWd 1.0)) (setq oldWd dpipepWd dpipepWd(getdist (strcat "\nSpecify first segment width <" (rtos dpipepWd) ">: ")) oldVars(mapcar 'getvar '("FILLMODE" "PLINEWID" "CMDECHO" "OSMODE")) ); end setq (if(null dpipepWd)(setq dpipepWd oldWd)) (mapcar 'setvar '("FILLMODE" "PLINEWID" "CMDECHO") (list 0 dpipepWd 1)); end mapcar (if(entlast)(setq lObj(entlast))) (vla-StartUndoMark (setq actDoc (vla-get-ActiveDocument (vlax-get-acad-object)))) (setq fPt (getpoint "\nSpecify start point: ") ); end setq (command "_.pline" fPt) (while(= 1(getvar "CMDACTIVE")) (command pause) ); end while (if (not (equal lObj(entlast))) (progn (setq lEnt(entlast) stLst(asmi-LayersUnlock) segLst(asmi-PlineSegmentDataList lEnt) vlaPln(vlax-ename->vla-object lEnt) ); end setq (setvar "OSMODE" 0) (setvar "CMDECHO" 0) (while (/= 1(length segLst)) (setq stDist (vlax-curve-getDistAtPoint vlaPln (caar segLst)) enDist (vlax-curve-getDistAtPoint vlaPln (caadr segLst)) ); end setq (if(< 2(length segLst)) (setq ang1 (+(/ pi 2)(angle(caar segLst)(caadr segLst))) ang2 (+(/ pi 2)(angle(caadr segLst)(car(nth 2 segLst)))) ); end setq ); end if (if (or (not Start) prDir );end or (setq plStart1 (vlax-curve-getPointAtDist vlaPln stDist) Start T); end setq (setq plStart1 (vlax-curve-getPointAtDist vlaPln (+ stDist(cadar segLst)))); end setq ); end if (if (or (equal ang1 ang2 0.000001) (= 2(length segLst)) ); end or (setq plEnd (vlax-curve-getPointAtDist vlaPln enDist) prDir T); end setq (setq plEnd (vlax-curve-getPointAtDist vlaPln (- enDist(cadar segLst))) prDir nil); end setq ); end if (if (< 2(length segLst)) (setq plStart2 (vlax-curve-getPointAtDist vlaPln (+ enDist(cadar segLst)))); end setq ); end if (if(< 2(length segLst)) (if (=(cadar segLst)(nth 2(car segLst))) (setq ptLst (mapcar '(lambda(x)(trans x 0 1)); end lambda (list(polar plEnd ang1 (/(cadar segLst)2)) (polar plEnd (+ pi ang1)(/(cadar segLst)2)) (polar plStart2 (+ pi ang2)(/(cadar segLst)2)) (polar plStart2 ang2 (/(cadar segLst)2)) ); end list ); end mapcar ); end setq (setq ptLst (mapcar '(lambda(x)(trans x 0 1)); end lambda (list (polar plStart1 ang1 (/(cadar segLst)2)) (polar plStart1 (+ pi ang1)(/(cadar segLst)2)) (polar(caadr segLst)(+ pi ang2)(/(nth 2(car segLst))2)) (polar(caadr segLst)ang2(/(nth 2(car segLst))2)) ); end list ); end mapcar ); end setq ); end if ); end if (setq plStart1(trans plStart1 0 1) plEnd(trans plEnd 0 1) ); end setq (if plStart2 (setq plStart2(trans plStart1 0 1)) ); end if (if (or (not(equal ang1 ang2 0.000001)) (/=(cadar segLst)(nth 2(car segLst))) ); end or (progn (setvar "PLINEWID" 0.0) (command "_.pline") (mapcar 'command ptLst)(command "_c") (setvar "PLINEWID" dpipepWd) ); end progn ); end if (if (not(equal ang1 ang2 0.000001)) (progn (setq lPln (vlax-ename->vla-object(entlast)) tAng(- ang2 ang1) ); end setq (if(minusp tAng)(setq tAng(- tAng))) (if (and (< 0 tAng) (>= pi tAng) ); end and (progn (vla-SetBulge lPln 1 (/(- ang2 ang1)4)) (vla-SetBulge lPln 3 (/(- ang1 ang2)4)) ); end progn (progn (vla-SetBulge lPln 1(/(- ang1 ang2)12)) (vla-SetBulge lPln 3(/(- ang2 ang1)12)) ); end progn ); end if ); end progn ); end if (if (=(cadar segLst)(nth 2(car segLst))) (command "_.mline" "_st" "DUCT_PIPE" "_S" (cadar segLst) "_J" "_Z" plStart1 plEnd "") ); end if (setq segLst(cdr segLst)); end setq ); end while (command "_.erase" lEnt "") (asmi-LayersStateRestore stLst) ); end progn ); end if (vla-EndUndoMark actDoc) (mapcar 'setvar '("FILLMODE" "PLINEWID" "CMDECHO" "OSMODE") oldVars); end apply (princ) ); end of c:dpipe ;FC FILLET WITH SPECIFIED RADIUS (defun C:FC () (command "FILLET" "RADIUS" 6 "FILLET") (princ) )
Categories: AutoCAD Customization, Autodesk Forums

block rename to attribute text value

Fri, 2013-05-17 14:30

hi

 

i wanna change my block name to attribute text value , somebody has a similar lisp code?

Categories: AutoCAD Customization, Autodesk Forums

Flip Color from bylayer to color and back

Fri, 2013-05-17 00:38

I am trying to flip between Bylayer and color 150. If cecolor is bylayer set cecolor to 150 and if cecolor is 150 set cecolor to bylayer. It seems so simple but it's not working.

 

(defun c:22 ()

  (setq cc (getvar "cecolor"))

    (cond 

      ((= cc "Bylayer")  (setvar "cecolor" "150") )

      ((/= cc "Bylayer") (setvar "cecolor" "Bylayer") )

    )

)

Categories: AutoCAD Customization, Autodesk Forums

substituting attributes

Thu, 2013-05-16 19:53

This is more of a training exercise for me.  I hope to someday use it but for now could someone help with with the following:

 

I isolated 3 attributes as you can see with my code.  My object is too take the value of blkDESC1 and set it as blktag, and then take blkDESC2 and set it as blkDESC1, and erase blkDESC2.  Any ideas?

 

(defun c:aup (/ dxf ent dxf1 ent1) (defun dxf (code ent) (cdr (assoc code (entget ent))))

(progn    (if  (and (setq ent (car (entsel "\nSelect an Attributed Block: ")))     

  (eq "INSERT" (dxf 0 ent))     

  (= 1 (dxf 66 ent)))      

  (while  (not (eq "TAG1" (dxf 2 (setq ent (entnext ent)))))             )          )  

  (setq blktag (dxf 1 ent))  

  (princ "\n")

(princ blktag)

(princ)

(while  (not (eq "DESC1" (dxf 2 (setq ent (entnext ent)))))             )   

 (setq blkDESC1 (dxf 1 ent))

(princ "\n")

(princ blkDESC1)

(princ)   

  (while  (not (eq "DESC2" (dxf 2 (setq ent (entnext ent)))))             )

(setq blkDESC2 (dxf 1 ent))

(princ "\n")

(princ blkDESC2)

(princ)

 

 

) 

Categories: AutoCAD Customization, Autodesk Forums

math in the foreach function

Thu, 2013-05-16 07:48

in the foreach function can you use math like (foreach pt1 (add 1) so that foreach one you pick it adds one the next one will be named pt2 then pt3 and so on

Categories: AutoCAD Customization, Autodesk Forums

Return name of different folders

Thu, 2013-05-16 02:14

Hello all,

 

The following gives me the first folder string, with no back-slashes, that the drawing exists in.

 

(setq FirstFolder
 ((lambda (/ tmpDir tmpPos)
 (substr
 (setq tmpDir (getvar "dwgprefix"))
 (+ 2 (setq tmpPos (vl-string-search "\\" tmpDir)))
 (- (vl-string-search "\\" tmpDir (1+ tmpPos)) (1+ tmpPos))))))

 

Is there a way to find the name of the second folder?

 

Is there a way to find the name of the third folder?

 

The string length of the characters for each of the first, second, third (and so on) folders are different, which means I can't count character using the "substr" function.

 

Thanks

KP

Categories: AutoCAD Customization, Autodesk Forums

Lisp Routine Help

Wed, 2013-05-15 22:20
I was wondering if I could get some assistance. I have pieced this lisp together from a few I have come across here in the groups, but am now stuck with the final pieces. Once the pline is drawn I would like the lisp routine to select the pline (last ?) instead of the user doing so. I would then like to offset the line 1 (foot) and then erase the original line drawn, so the user does not have to. Any assistance would be GREATLY appreciated..Thanks (defun c:Test ( / *error* of undo doc ss )  (vl-load-com)   (command "pline")(while (> (getvar "cmdactive") 0) (command pause))   (defun *error* ( msg )    (and undo (vla-EndUndomark doc))    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")        (princ (strcat "\n** Error: " msg " **")))    (princ)   )   (if (and (ssget '((0 . "ARC,CIRCLE,ELLIPSE,*LINE")))           (setq of (getdist "\nSpecify Offset Distance: ")))    (progn      (setq undo        (not          (vla-StartUndomark            (setq doc              (vla-get-ActiveDocument                (vlax-get-acad-object)              )            )          )        )      )            (vlax-for obj (setq ss (vla-get-ActiveSelectionSet doc))        (mapcar          (function            (lambda ( o )              (vl-catch-all-apply                (function vla-offset) (list obj o)              )            )          )          (list of (- of))        )      )      (vla-delete ss)       (setq undo (vla-EndUndoMark doc))    )  )  (princ))
Categories: AutoCAD Customization, Autodesk Forums

unlocking dxf codes

Wed, 2013-05-15 17:18

I am trying to change a viewport scale through the dxf code:  I see that certain parts cannot be changed but I don't know if this is one of them.  Here's what I have so far:

 

(defun c:vps ()

(setq quickview (entget(car(entsel))))

 (setq g45 (cdr(assoc 45 quickview))) 

(setq g41  (cdr(assoc 41 quickview)))

 (setq new1 (* g45 1.5)) 

(entmod (subst (cons 41 new1) (assoc 41 quickview) quickview))

 )

The scale is a ratio between m-space height & p-space height.  So if I want all viewports to be 1:1.5 scale this is what I need to do, but my entmod command isn't working is there another way?

Categories: AutoCAD Customization, Autodesk Forums

Finding and replacing "very" special characters

Wed, 2013-05-15 13:50

Is there a way to find and/or replace "very" special characters like [carriage return], [backspace] or even [tab mark], considering that the first thing that comes to mind when saying special characters is the standard and extended ASCII only.

 

Thanks,

Categories: AutoCAD Customization, Autodesk Forums

I want to Make a Custom Toolbar Control

Wed, 2013-05-15 09:28

Hi, Greetings from mexico (I apologize for my bad English)

 

Can anybody tell me if can i develop a "Custom Toolbar Control" to Display or Set Entity's Elevation,

and place it in the Properties toolbar.

 

I have the ability to program in AutoLISP language, Diesel and customization with MNL and DCL files.

So, do I need more knowledge?...Or is it simply impossible?.

 

I thank you in advance for the attention to my post.

 

Categories: AutoCAD Customization, Autodesk Forums
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • …
  • next ›
  • last »

Individual forums:
- Visual LISP, AutoLISP and General Customization
- Visual Basic Customization
- Autodesk ObjectARX
- .NET

    © Copyright 2013 Autodesk, Inc. All Rights Reserved. Legal Notices & Trademarks - Privacy Policy