![]() |
|
|||||||
| AutoLISP Ask questions, give examples or troubleshoot your lisp programs. Feel free to post your code here (NO commercial adversiting). |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Senior Member
Join Date: Jan 2009
Location: Anchorage, Alaska
Posts: 203
|
In your code you are using Pt1 like an real number, z value, is this what you meant? if so you should use "getreal" to prompt & obtain the value.
next, to combine a z value into a point it's cleaner to treat it as a number rather than a string. "0,0,pt1" is not recognized by autocad as valid. Create a point list with; (setq Zval 1200) (setq basept (list 0 0 Zval)) (command "move "en "" basept etc....) |
|
|
|
|
|
#12 |
|
Member
Join Date: Feb 2010
Posts: 40
|
Hello,
Thanks again. I manage to do a program that moves the plines only in Z direction. I can't manage to filter the z coordinate of one point and use to move. Its like the zval and zval2 is only the z coordinate and comes from a know point or a user input. My program is now as follows: (defun myprog3 () (setq en (car (entsel "\nSelect a pline to move: "))) (setq pt1(getpoint "\n Base Point: ")) ;store base point (setq pt2(getpoint "\n Displacement Point: ")) ;store displacement pt (setq Zval 0) (setq Zval2 1200) (setq basept (list 0 0 Zval)) (setq topoint (list 0 0 Zval2)) (command "move" en "" basept topoint) ) How can i manage to filter only the z coordinate? Because if i manage to filter it, i can move the boundary from the plane xy, yz or zx to the last location, known for the point of the internal space we inputed earlier? Best regards |
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Jan 2009
Location: Anchorage, Alaska
Posts: 203
|
The return from a getpoint will be a list, such as (23.45 56.88 1200.0)
To get the third value from the list, can use either; (setq Zval (nth 2 Pt1));0 is first, 2 is third -or- (setq Zval (caddr Pt1));'car is first, cadr second, ... |
|
|
|
|
|
#14 |
|
Member
Join Date: Feb 2010
Posts: 40
|
Hello,
Thanks again. It is now working. Here is the program: (defun a () (setq Pt1 (getpoint "\nSelect outside point: ")) ; Seleciona um ponto na fronteira para ver a sua coordenada z (setq zval1 (nth 2 Pt1)) (setq Pt2 (getpoint "\nSelect internal point: ")) ; Seleciona um ponto interno para ver fazer o boundary (setq basept (list 0 0 0)) ; Ponto base (setq topoint (list 0 0 Zval1)) ; Ponto onde estava a peça (command "boundary" Pt2 "") ; Faz o boundary (command "extrude" (entlast) "" "8" ) ; Dá espessura à peça (command "move" (entlast) "" basept topoint) ; Faz o move da peça de volta à sua origem ) The extruded pline is now on the inicial plane but not in the inicial layer. How can I change the layer in Autolisp? Best regards |
|
|
|
|
|
#15 |
|
Senior Member
Join Date: Jan 2009
Location: Anchorage, Alaska
Posts: 203
|
You could change the layer of the polyline before you extruce it, or of the solid after extruding.
Look at the command sequence for "change" or "chprop" command. |
|
|
|
|
|
#16 |
|
Member
Join Date: Feb 2010
Posts: 40
|
Hello,
I used this expression: (vl-cmdf "_.chprop" (ssget) "" "_la" "0" ""); To change the layer to a layer named 0 for instance. My question is how can I automatically change the object layer from the "layer 0" to the object's previous layer? Like getting the object's properties from the first object, store them and apply its layer name in the expression above? Best regards |
|
|
|
|
|
#17 |
|
Senior Member
Join Date: Jan 2009
Location: Anchorage, Alaska
Posts: 203
|
An object's "group code" or "dxf code" is used in the lisp approach to manipulate object properties.
To obtain properties of last created object; (Setq edata (entget (entlast)) For the layer: (setq layername (cdr (assoc 8 edata))) |
|
|
|
|
|
#18 |
|
Member
Join Date: Feb 2010
Posts: 40
|
Hello,
Thanks. I have made as this: (defun a () (setq peca (car (entsel "\nSelect a line of the boundary: "))) (Setq edata (entget (entlast))) (setq layername (cdr (assoc 8 edata))) (setq Pt1 (getpoint "\nSelect outside point: ")) (setq zval1 (nth 2 Pt1)) (setq Pt2 (getpoint "\nSelect internal point: ")) (setq basept (list 0 0 0)) (setq topoint (list 0 0 Zval1)) (command "boundary" Pt2 "") (command "extrude" (entlast) "" "1000" ) (command "move" (entlast) "" basept topoint) (command "_.chprop" (entlast) "" "_la" layername "") ) Now for the second part... For this program to work I have to click first in a line of the object for it to memorise the inicial layer, after to click in a point in a line to memorise the z coordinate and after to click in an internal point to be able to to the boundary. It will extrude to a thickness that i can input or to use in the code, move it to the inicial location and finally change to it's inicial layer. Is there anyway to this by having a excel or any other type of file with two columns, one with the layer name and the other with the thickness of each object and do the a command to read the file and automatically do the boundary, extrude and do the move ? Best regards |
|
|
|
|
|
#19 |
|
Senior Member
Join Date: Jan 2009
Location: Anchorage, Alaska
Posts: 203
|
It should be possible to create your extrusions with fewer clicks. And yes it's even possible to put some of this data in a file to lessen user input even more (but you have to put the info in a file though...)
I don't really know what your process is to help with other shortcuts, but I can suggest a method to only click 1 time per extrusion. try the following. And you'll probably beed to debug this as I haven't tried it or checked spelling, just typed it out... Code:
(defun a ()
(setq basept (list 0 0 0))
(initget 6)
(while
(setq Extr_Dist (getreal "\nEnter extrude distance: "))
(setq Pt2 (getpoint "\nSelect internal point: "))
(command "boundary" Pt2 "")
(setq Edata (entget (entlast)));;get polyline data
(setq PtPl1 (cdr (assoc 10 Edata)))
(setq PtPl2 (cdr (assoc 10 (reverse Edata))))
(setq ss_fence (ssget "_F" (list PtPl1 PtPl2) '((0 . "LINE"))));select lines
(setq LineEnt (ssname ss_fence 0))
(setq LineEl (nth 2 (cdr (assoc 10 (entget LineEnt)))))
(setq topoint (list 0 0 LineEl))
(setq LineLyr (cdr (assoc 8 (entget LineEnt))))
(command "extrude" (entlast) "" Extr_Dist)
(command "move" (entlast) "" basept topoint)
(command "_.chprop" (entlast) "" "_la" LineLyr "")
(initget 6)
);while
(princ)
)
)
Last edited by CarlAK; 03-09-2010 at 09:22 PM. Reason: **fixed a few bugs...** |
|
|
|
|
|
#20 |
|
Member
Join Date: Feb 2010
Posts: 40
|
Hello
I used your code and only had to includ one ")". The problem it is not changing the layer... Can you tell me what is the meaning of some of the lines so that i can learn? Here is the code: (defun a () (setq basept (list 0 0 0)) ; Sets the base point (initget 6) ; What does this do? (while ; While cycle (setq Extr_Dist (getreal "\nEnter extrude distance: ")) ; User sets thickness of the extrude (setq Pt2 (getpoint "\nSelect internal point: ")) ; User sets the internal point (command "boundary" Pt2 "") ; Executes the command extrude (setq Edata (entget (entlast))) ; Gets the las point selected (setq PtPl1 (cdr (assoc 10 Edata))) ; What does this do? (setq PtPl2 (cdr (assoc 10 (reverse Edata)))) ; What does this do? (setq ss_fence (ssget "_F" (list PtPl1 PtPl2) '((0 . "LINE")))) ; what does this do? (setq LineEnt (ssname ss_fence 0)) ; what does this do? (setq LineEl (nth 2 (cdr (assoc 10 (entget LineEnt))))) ; what does this do? (setq topoint (list 0 0 LineEl)) ; Sets the point to move the extrude (setq LineLyr (cdr (assoc 8 (entget LineEnt)))) ; What does this do? (command "extrude" (entlast) "" Extr_Dist) ; Extrudes (command "move" (entlast) "" basept topoint) ; Moves (command "_.chprop" (entlast) "" "_la" layername "") ; Changes the layer (initget 6) ; What does this do? );while (princ) ) Thanks |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|