Qonfire Posted December 5, 2011 Posted December 5, 2011 (defun c:hlines ( / *error* g1 g2 gr h l ms p p1 p2 v ) ;; Lee Mac 2011 (defun *error* ( m ) (redraw) (princ)) (or *n (setq *n 3)) (if (setq p1 (getpoint "\nSpecify First Corner: ")) (progn (setq ms (princ "\nSpecify Opposite Corner [+/-]: ")) (while (progn (setq gr (grread t 15 0) g1 (car gr) g2 (cadr gr)) (cond ( (= 5 g1)(redraw) (setq h (- (car g2) (car p1)) v (/ (- (cadr g2) (cadr p1)) (1+ *n)) p p1 ) (repeat *n (setq p (list (car p) (+ v (cadr p)) (caddr p))) (grdraw p (list (+ (car p) h) (cadr p) (caddr p)) -1) ) (setq l (list p1 (list (+ (car p1) h) (cadr p1) (caddr p1)) g2 (list (car p) (+ v (cadr p)) (caddr p)) ) ) (mapcar '(lambda ( a b ) (grdraw a b 1 -1)) l (append (cdr l) (list (car l)))) ) ( (= 2 g1) (cond ( (member g2 '(45 95)) (if (= 1 *n) (princ (strcat "\n--> Minimum Number of Lines Reached." ms)) (setq *n (1- *n)) ) ) ( (member g2 '(43 61)) (setq *n (1+ *n)) ) ) ) ( (= 3 g1) (setq h (- (car g2) (car p1)) v (/ (- (cadr g2) (cadr p1)) (1+ *n)) ) (repeat *n (setq p1 (list (car p1) (+ v (cadr p1)) (caddr p1))) (entmakex (list (cons 0 "LINE") (cons 10 (trans p1 1 0)) (cons 11 (trans (list (+ (car p1) h) (cadr p1) (caddr p1)) 1 0)) ) ) ) nil ) ) ) ) ) ) (redraw) (princ) ) Quote
Qonfire Posted December 5, 2011 Author Posted December 5, 2011 (edited) (setq ms (princ "\nSpecify Opposite Corner [+/-]: ")) (while (progn (setq gr (grread t 15 0) g1 (car gr) g2 (cadr gr)) ;;[color=blue](grread t 15 0) returns (5(x,y,z)) so as g2 we store x,y,z why do want to confirm that (car gr) equal to 5 next line[/color] (cond ( (= 5 g1)(redraw) (setq h (- (car g2) (car p1)) v (/ (- (cadr g2) (cadr p1)) (1+ *n)) ;;[color=blue] i guess h is x dist,v,vertical distance the point of most interest why (1+*n) [/color] p p1 ) (repeat *n (setq p (list (car p) (+ v (cadr p)) (caddr p))) (grdraw p (list (+ (car p) h) (cadr p) (caddr p)) -1) ) Use Code Tags even for snippits of code CODE POSTING GUIDELINES. SLW210 Edited December 8, 2011 by SLW210 ADD Code Tags!!! Quote
alanjt Posted December 5, 2011 Posted December 5, 2011 Instead of re-posting Lee's code, why not ask him directly or in the thread where you found the code? Quote
Qonfire Posted December 5, 2011 Author Posted December 5, 2011 ALANJT I don't really have an answer for you. I have a block ,I would like to change its cylindrical hatch color, (entget) is not providing this groupe code please give me a tip. Quote
Lt Dan's legs Posted December 5, 2011 Posted December 5, 2011 type vlide in the command prompt now hit F1 Quote
BlackBox Posted December 5, 2011 Posted December 5, 2011 please give me a tip. I'm no expert Qonfire, but perhaps this quote will help you: Instead of re-posting Lee's code, why not ask him directly or in the thread where you found the code? Good luck! Quote
Qonfire Posted December 6, 2011 Author Posted December 6, 2011 (edited) I guarantee new thread not because I don't want the answer. I thought that was an old thread why don't I start a new thread, because I might have further questions in regards of modifying Lee's lisp to my needs. I didn't want to ask repeatedly one person. It might get tiring, I thought. So I explode it. Since, I had another question here I don't want to lose this thread and I will follow your advice. Thanks Lt Dan's legs I will check this now regards Edited December 6, 2011 by Qonfire Quote
Lee Mac Posted December 6, 2011 Posted December 6, 2011 Hi Qonfire, Is there a particular part of the code you wish for me to explain? Lee Quote
Qonfire Posted December 7, 2011 Author Posted December 7, 2011 am I lucky or what? Hello Lee I've been using actively autocad at work for the past year. I see advantages of customizing work with Autolisp and Vlisp. I've been searching and reading on this stuff. Can Vlisp replace completely Autolisp? What is based decision where it is better to use Autolisp or Vlisp? Sometime I see them combined. I want to come back to thread defun c:hlines later with a clear question, but i tried to formulate question in the second post. Now ,I would like to know how to change the cylindrical hatch color of a scaled block to another color, using lisp. Whats a best way to access this property. Thanks Quote
Lee Mac Posted December 7, 2011 Posted December 7, 2011 I've been using actively autocad at work for the past year. I see advantages of customizing work with Autolisp and Vlisp. I've been searching and reading on this stuff.Can Vlisp replace completely Autolisp? What is based decision where it is better to use Autolisp or Vlisp? Sometime I see them combined. Visual LISP (previously 'Vital LISP') is an extension (not a replacement) for 'Vanilla' AutoLISP. You cannot create programs using purely Visual LISP (since 'defun' and most other basic functions are part of Vanilla AutoLISP), but you can create programs using only Vanilla AutoLISP (indeed, this is necessary when developing programs compatible with a Mac). Visual LISP itself can be categorised: there are elements that are included for convenience but which could be replicated using Vanilla AutoLISP (such as the vl-string-* functions, or perhaps vl-remove-*). Then there are the reactor functions which may be viewed in a similar way to 'Events'; these cannot be replicated using Vanilla AutoLISP. Finally, there are the ActiveX functions derived from the AutoCAD Object Model. This is a 'grey area' since some areas of the Object Model have equivalents in Vanilla AutoLISP (such as Collections Tables, also Dictionaries / XRecords), however, some parts of the Object Model are only accessible through Visual LISP (such as the Preferences object). Furthermore, Visual LISP offers the opportunity to interface with Objects outside of the AutoCAD Object Model, (for example, MS Office / FSO / WSH etc etc). Now ,I would like to know how to change the cylindrical hatch color of a scaled block to another color, using lisp. Whats a best way to access this property. Since the object is within a block, you would need to access the Block Definition from the Block Table / Collection [Vanilla / Visual], then iterate through the objects within the definition (using entnext / vlax-for [Vanilla / Visual] ), then modify the hatch entity / object within the definition (this change will then be applied to all Inserts / References). Quote
stevesfr Posted December 7, 2011 Posted December 7, 2011 Lee or Alan.. If vl-* is based on Visual Lisp (formerly Vital Lisp), what is vla-* based on ? slow but sure... starting to differentiate and see the lights.. Steve Quote
Lee Mac Posted December 7, 2011 Posted December 7, 2011 Lee or Alan..If vl-* is based on Visual Lisp (formerly Vital Lisp), what is vla-* based on ? slow but sure... starting to differentiate and see the lights.. Steve The vla-* functions are ActiveX properties and methods of the AutoCAD Object Model, the vla-* prefix is assigned by the type-library, (for example, you can assign a different prefix by importing a type-library when interfacing with objects outside of the AutoCAD Object Model). For example, the function: (vla-addmtext <Block> <Point> <Width> <Text>) is created by the AutoCAD type-library and is equivalent to: (vlax-invoke-method <Block> "addmtext" <Point> <Width> <Text>) Quote
Qonfire Posted December 7, 2011 Author Posted December 7, 2011 (setq t (tblsearch "BLOCK" "NP")) ((0 . "BLOCK") (2 . "NP") (70 . 0) (4 . "") (10 0.0 0.0 0.0) (-2 . <Entity name: 7ef034a8>)) ;; hatch entity of a block is not shown yet. (SET k (entnext t)) ;; I have to assign [color="red"]t[/color] to entnext? ; error: bad argument type: lentityp ((0 . "BLOCK") (2 . "NP") (70 . 0) (4 . "") (10 0.0 0.0 0.0) (-2 . <Entity name: 7ef034a8>)) ;;is the last line how its suppose to be? thank you Quote
Lee Mac Posted December 7, 2011 Posted December 7, 2011 Not quite, consider the following: (if (setq ent (tblobjname "BLOCK" "NP")) ;; Get the 'BLOCK' entity (while (setq ent (entnext ent)) ;; Iterate through the entities in the definition (setq elst (entget ent)) ;; Get DXF Data of entity (if (eq "HATCH" (cdr (assoc 0 elst))) ;; If the entity is a Hatch... (entmod (append elst '((62 . 3)))) ;; Change it to green ) ) ) (command "_.regen") ;; Regen to show changes Quote
Qonfire Posted December 7, 2011 Author Posted December 7, 2011 Thanks for clarification, Let me digest this:) Quote
Qonfire Posted December 7, 2011 Author Posted December 7, 2011 _$ (setq ent (tblobjname "BLOCK" "NP")) ;; Get the 'BLOCK' entity (while (setq ent (entnext ent)) ;; Iterate through the entities in the definition (setq elst (entget ent))) <Entity name: 7ef864a0> ((-1 . <Entity name: 7ef864b0>) (0 . "LWPOLYLINE") (330 . <Entity name: 7ef86490>) (5 . "176") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbPolyline") (90 . 4) (70 . 1) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10 0.0 -0.5) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 1.0 -0.5) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 1.0 0.5) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 0.0 0.5) (40 . 0.0) (41 . 0.0) (42 . 0.0) (210 0.0 0.0 1.0)) I'm stuck here (if (eq "HATCH" (cdr (assoc 0 elst))) ;; My quess is that "hatch" is associated with one of these dxf code above( 5. ---),(67. ---) etc.If "hatch" is not an entity from a list above than how does it set (if (eq "hatch"......Also dxf code 62. is not prsent in dxf code obtained from entget appreciated greatly Quote
Lee Mac Posted December 8, 2011 Posted December 8, 2011 Here is a DXF Reference for you: 2011 DXF Reference From here we can see that DXF Group 0 is the Entity Type. So the code: (cdr (assoc 0 elst)) Will return the Entity Type of the DXF Data List, in this case we are looking for a HATCH entity. Concerning Colours: DXF Group code 62 controls entity colour, however, if the colour of an entity is set to ByLayer, the DXF Group 62 will not be present in the DXF list. Now for this line: (entmod (append elst '((62 . 3)))) ;; Change it to green In the above line of code, I am actually exploiting a quirk when updating the entity colour wherein if the DXF Group code 62 is not present, it is appended to the end of the DXF data list and the colour is updated; however, if the DXF Group code 62 is present we now have two DXF Group codes in the DXF Data list, the 'quirk' is that entmod will honour the DXF value that has been appended and will update the colour accordingly. This would be perhaps more 'correctly' written as: (if (setq pair (assoc 62 elst)) (entmod (subst '(62 . 3) pair elst)) (entmod (append elst '((62 . 3)))) ) Quote
Qonfire Posted December 8, 2011 Author Posted December 8, 2011 (setq ent (tblobjname "BLOCK" "NP")) ;; Get the 'BLOCK' entity (while (setq ent (entnext ent)) ;; Iterate through the entities in the definition. Are we looking at this point on the entities (properties) that block "NP"has or entities of the objects in drawing? (setq elst (entget ent) Here, I believe we are calling on the entities of the block.So if block is composed of lwpolyline and hatch,why this lines returns only (0. "lwpolyline") where is (0. "Hatch")? Why entget doesn't give full set of entities of block "np"? I hope my question is clear. Thankx for tutoring Quote
Lee Mac Posted December 8, 2011 Posted December 8, 2011 (setq ent (tblobjname "BLOCK" "NP")) ;; Get the 'BLOCK' entity (while (setq ent (entnext ent)) ;; Iterate through the entities in the definition. Are we looking at this point on the entities (properties) that block "NP"has or entities of the objects in drawing? Entities are not properties, they are objects. Here we are looking at entities that make up the Block Definition of the block "NP". (setq elst (entget ent) Here, I believe we are calling on the entities of the block.So if block is composed of lwpolyline and hatch,why this lines returns only (0. "lwpolyline")where is (0. "Hatch")? Why entget doesn't give full set of entities of block "np"? No, (entget ) returns the DXF data for a single supplied entity. I would suggest that you use the VLIDE Help Documentation to study the purpose of each function I have used. I have written a short tutorial on how to access this help here. Quote
Qonfire Posted December 10, 2011 Author Posted December 10, 2011 I think I've a slightly better image about talk we talked here, but a funny thing is, that if a hatch is a cylindrical the changed color graphically doesn't appear, however it has the assigned color. Weekend, http://www.jefferypsanders.com, here I come No further questions for now,thank you all:) Quote
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.