CadFrank Posted July 25, 2011 Share Posted July 25, 2011 Hi, i have a routine and i would like to add a action to it. this routine is a dynamic block counter, the result of the count shows in the command prompt line so i would like to make this command prompt open at the end of the count. This code was not created by me since im very new at autolisp. I'm not sure if the autor is RenderMan but he is the one that gave it to me. so here it is. (defun c:BCD () (c:BlockCountDynamic)) (defun c:BlockCountDynamic ( / ss item val valList) (vl-load-com) (princ "\rBLOCK COUNT: DYNAMIC ") ;| (if (setq ss (ssget "_x" (list '(0 . "INSERT") '(2 . "*U*") ; <-This part of filter won't register for some reason? (cons 410 (getvar 'ctab))))) |; (if (setq ss (ssget "_x" (list '(0 . "INSERT") (cons 410 (getvar 'ctab))))) (progn (vlax-for x (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))) (if (and (= :vlax-true (vla-get-isdynamicblock x)) (setq val (vlax-get (car (vlax-invoke x 'getdynamicblockproperties)) 'value))) (if (setq item (assoc val valList)) (setq valList (subst (cons val (1+ (cdr item))) item valList)) (setq valList (cons (cons val 1) valList))))) (foreach item (vl-sort valList '(lambda (x y) (< (car x) (car y)))) (prompt (strcat "\n >> " (car item) " Total = " (rtos (cdr item) 2 0)))) (vla-delete ss)) (prompt "\n** Nothing selected ** ")) (princ)) Thanks for the help. Quote Link to comment Share on other sites More sharing options...
pBe Posted July 25, 2011 Share Posted July 25, 2011 (edited) (textscr) ? (2 . "`*U*") instead of (2 . "*U*") Edited July 25, 2011 by pBe Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 25, 2011 Author Share Posted July 25, 2011 well i'm not completly sure but i dont think it change much. But what i wanted exactly is to execute the f2 shortcut at the end of the count. AutoCad calls the window " autocad text window" i can leave a picture of it might help understant what a want. so here it is hope it will help understand what i want. Quote Link to comment Share on other sites More sharing options...
pBe Posted July 25, 2011 Share Posted July 25, 2011 paste that (textscr) on your command prompt and you shall see or place (textscr) before the end of the last ")" (prompt "\n** Nothing selected ** ")) (princ)[color=blue](textscr)[/color]);<----- and yes (2 . "`*U*") will work with the selection filter I tested your code with the modificatiions and it works fine Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 25, 2011 Author Share Posted July 25, 2011 Ok thanks alot for your help! ill let you know if it works. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 25, 2011 Share Posted July 25, 2011 Hi, i have a routine and i would like to add a action to it. this routine is a dynamic block counter, the result of the count shows in the command prompt line so i would like to make this command prompt open at the end of the count. CadFrank - When you have a question about code provided you in another thread, your question would be best answered in the original thread. This code was not created by me since im very new at autolisp. I'm not sure if the autor is RenderMan but he is the one that gave it to me. I (RenderMan) am the author of the code your question is in regards to. To answer your question... Both (textscr), and (textpage) will open the AutoCAD Text Window (F2), and (graphscr) will return focus to the main application. Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 25, 2011 Author Share Posted July 25, 2011 Well it works so its all good ! i would like to know if you would know of any good books to learn autolisp that could help me understand the language. Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 25, 2011 Author Share Posted July 25, 2011 Sry i though it was to far in the list for people to see it since im new to forom i dont understand them yet but in the future i will. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 25, 2011 Share Posted July 25, 2011 Well it works so its all good ! i would like to know if you would know of any good books to learn autolisp that could help me understand the language. The Visual LISP Developer's Bible, 2011 Edition Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 25, 2011 Share Posted July 25, 2011 Sry i though it was to far in the list for people to see it since im new to forom i dont understand them yet but in the future i will. No worries; Now you know... Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 25, 2011 Author Share Posted July 25, 2011 What is the diffence between visual lisp and autolisp? Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 25, 2011 Author Share Posted July 25, 2011 I bought a book called "programmer autocad avec Diesel" its a french book since im french i was wondering if it was good. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 25, 2011 Share Posted July 25, 2011 What is the diffence between visual lisp and autolisp? That's a loaded question, but to try to answer you: AutoLISP is a programming language designed for extending and customizing AutoCAD functionality. It is based on the LISP programming language, whose origins date back to the late 1950s. LISP was originally designed for use in Artificial Intelligence (AI) applications, and is still the basis for many AI applications. AutoCAD introduced AutoLISP as an application programming interface (API) in Release 2.1, in the mid-1980s. LISP was chosen as the initial AutoCAD API because it was uniquely suited for the unstructured design process of AutoCAD projects, which involved repeatedly trying different solutions to design problems. Visual LISP (VLISP) is a software tool designed to expedite AutoLISP program development. The VLISP integrated development environment (IDE) provides features to help ease the tasks of source-code creation and modification, program testing, and debugging. In addition, VLISP provides a vehicle for delivering standalone applications written in AutoLISP. In the past, developing AutoLISP programs for AutoCAD meant supplying your own text editor for writing code, then loading the code into AutoCAD and running it. Debugging your program meant adding statements to print the contents of variables at strategic points in your program. You had to figure out where in your program to do this, and what variables you needed to look at. If you discovered you still didn't have enough information to determine the error, you had to go back and change the code again by adding more debugging points. And finally, when you got the program to work correctly, you needed to either comment out or remove the debugging code you added. linky Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 25, 2011 Author Share Posted July 25, 2011 well thanks for the answer ill see if i can get my hands on the book. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 25, 2011 Share Posted July 25, 2011 I bought a book called "programmer autocad avec Diesel" its a french book since im french i was wondering if it was good. Je ne suis pas français, je ne sais donc pas, mon ami. English: I am not French, so I do not know, my friend. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.