• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

create new layers for object types and group in lsp

  • Thread starter Thread starter mazzetti68
  • Start date Start date

mazzetti68

Guest
Hello, everyone!
I would like to create in lsp, a function that when creating a data line two points:
Code:
(setq p1 (getpoint "\nindicates the starting point of the panel line: ")
(setq p2 (getpoint "\nindicates the end point of the panel line: ")
(setq p1x (nth 0 p1))
(setq p1y (nth 1 p1))
(setq p1z (nth 2 p1))
(setq p1+6 (list(+ p1x 0.06) p1y p1z))

(setq p2x (nth 0 p2))
(setq p2y (nth 1 p2))
(setq p2z (nth 2 p2))
(setq p2-6 (list p2x p1y p1z))

(command "_line" p1+6 "_non" p2-6 ")
create this line on a new layer. (color 2, called "line")

and create another one when I make a circle: (color 10, called "circle")
Code:
(setq c1 (getpoint "\nindicates the point of the center of the circle: ")
(setq c2 (getpoint "\nindicates the radius amplitude point: ")

(command "_circle" c1 c2)
(Make the two codes are attached)

later everything is grouped (autocad group, instead of block).

Thank you in advance and... good afternoon to all! !
 
I answer for the first part, the other one is unclear.. a select everything to create a block with created objects?

Anyway:
(vl-load-com)
(setq acadobject (vlax-get-acad-object))
(setq activedocument (vla-get-activedocument acadobject))
(setq layertable (vla-get-layers activedocument))
. ..
(vla-put-color (vla-add layertable "nome_layer") colore_in_numero)
(vla-put-activelayer activedocument (vla-item layertable "nome_layer"))
;oggetto da disegnare
 
Code:
(setq c1 (getpoint "\nindicates the point of the center of the circle: ")
(setq c2 (getpoint "\nindicates the radius amplitude point: ")

(command "_circle" c1 c2)
regarding this portion of code, the whole list can be reduced simply to:
(command "_cicle" breaks), leaving you the possibility not only to click a point for the circle radius, but also to type it numerically
 
thank you very much dr.lube just what I needed:smile:! ... to tell the truth I thought it was much more complicated and along the process. . .
for the group I mean that what I have just created is inserted into a new group (that key dx, -->group -->group). for example that if I repeat my lsp, which creates three lines, every time I create a block with inside these three lines... I hope you understand.. .

crystal you are right, I had not thought about it, put them so it is useless...that to me then those points that I appointed c1 and c2, serve to create forms of a cartilage, and I extrapolated only one part to make understand the sense of my trouble, senno I was getting a post from 1km of only code;)

I forgot... With my lsp you create a mess of points, so how do I erase them from temporary memory? Is it possible to reset it or something? in the sense that if I start a second time the lsp it hooks up to points created at the previous start, es c1a c1b depend on other points...even if I gave a new starting position x, y and z.

I hope I've been clearer

Good evening to all
 
g
I forgot... With my lsp you create a mess of points, so how do I erase them from temporary memory? Is it possible to reset it or something? in the sense that if I start a second time the lsp it hooks up to points created at the previous start, es c1a c1b depend on other points...even if I gave a new starting position x, y and z.
The streets are 2:
or create temporary variables:
(defun c:prova (/ var1 var2 var3 var4...)
in this case the variables will exist only at the stage when the program turns then disappear

oppura at the end of the procedure the emptied and therefore and as if they were never existed
(Sectq var1 nil var2 nil var3 nil... )
 
Thank you crystal! just what I needed:

to create the block, of the objects just created, I searched a lot on the net, but nothing:( ... then I had come to mind to immediately define the command "_group" and then insert in some way the code of the part that goes to be inside the group: I clarify with an example: (which is certainly not correct, but from the idea, at least hope)
Code:
[COLOR="#FF0000"](command "_group"[/COLOR](setq p1 (getpoint "\nindicates the starting point of the panel line: ")
(setq p2 (getpoint "\nindicates the end point of the panel line: ")
(setq p1x (nth 0 p1))
(setq p1y (nth 1 p1))
(setq p1z (nth 2 p1))
(setq p1+6 (list(+ p1x 0.06) p1y p1z))

(setq p2x (nth 0 p2))
(setq p2y (nth 1 p2))
(setq p2z (nth 2 p2))
(setq p2-6 (list p2x p1y p1z))

(command "_line" p1+6 "_non" p2-6 ")[COLOR="#FF0000"])[/COLOR]
Is it possible to do something like that? or maybe there's another way?

Thank you very soon

Good evening to all!
 
Hello, everyone!
I had left aside this problem that I have not yet managed to solve, the group function I think is to let go ... the other option would be the creation of a block, only that I would leave the process to choose what to select and then insert inside the block the selection (as you usually do), I would do an automated thing, that just create one or more line are inserted in the block.
Do you know if it's possible? and how could you do it?
Thank you in advance and wish you a good evening to all!
 
the function (entlast) returns the object just created. you do nothing but list all these items and add them to the block :)
 
thank you very much dr.lube for confirmation :smile:, now I am ready to start, or almost .... I did not understand how you intend to list all the objects I create, and add them to the block....I could ask for a practical example... ?
Thank you again!
 
Hello, everyone!
I searched the internet, how to apply this function, in the sense I can only extract the name of the entity. but I can't put them on the list, does anyone have a practical example to share?
Thank you in advance.
Good evening to all!
 
Sorry I'm late.
Code:
(defunc c:test (/)
(setq all nil) ; reset the variable
(setq all (ssadd) ; initialize the variable
(repeat 5)

(ssadd (car (entsel) all) ; you need entlast, I did so to try if it went, car to extract only the name object

)
)

:)
 
Thank you for your time! I tried to use the function, as well as in your empio....I tried to extract it as text, but autocad gives me error:
Code:
command: ; error: type of wrong subject: cons <nome 7ff667d15070="" entità:=""></nome>
Code:
(defun test (/)
(setq all nil)
(setq all (ssadd))
(repeat 5 (ssadd (car (entlast)) all))
)
(command "_line" pause "")
(test)
(command "_text" "_br" pause "2" "0" all)
You know why?

Hello and good evening to all!
 
Code:
_$ (setq pippo (entlast)
<nome 7ffff905d60="" entità:=""></nome>
Code:
_$ (setq pippo (entsel)
(<nome 7ffff905d60="" entità:=""> (2504.62 1704.4 0.0)</nome>
look what the two methods return, do you understand the need to use (car ..) to extract the first element from the entsel?

in your case, entlast, only the name of the object is returned, without the coordinates. then remove the (car ...)
 
Thank you very much! It is clear to remove car, to have only the name of the object....but autocad still returns me error.. . :
Code:
; error: function canceled
and the code...
Code:
(defun test (/)
(setq all nil)
(setq all (ssadd))
(repeat 5 (ssadd (entlast) all))
)
(command "_line" pause "")
(test)
(command "_text" "_br" pause "2" "0" all)
Can you help me again?
 
Code:
 (setq all nil)
(setq all (ssadd))
with (ssadd) the variable is initialized, therefore the first line is useless.

Code:
(repeat 5 (ssadd  (entlast) all))
add 5 times same object to the selection group, then the group will be composed of that only object.


I didn't understand what you have to do, write the name of the object (line)?
 
but in fact I repeat I put it to try the function and understand it, with the entsel it made sense.. It seemed to me that without the first line the list remained with the elements inside when I relaunched the program. the items to add to the list you have to put them inside the repeat cycle, while or what you need. .
(conditions for the cycle

(setq all (ssadd))
(command "_line"...)

(sighs)

(command "_text"...)

(sighs)
) ; end cycle

Sorry I'm from the phone:)
 
Thank you very much gp and dr.lube
x gp: for the line I wanted to try to see if I could write the name of the object, because I couldn't create a group, in the sense I searched on the internet but the right syntax I didn't find it, like certain use _insert and other _block..., you know what it is used, or is it better, in the quickest sense? and how, inserting the name of the object?
hello and thank you in advance!
Have a good day! !
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top