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

replace points with a block

  • Thread starter Thread starter Andrea Bertocco
  • Start date Start date

Andrea Bertocco

Guest
Hello everyone,
I was wondering if there is a procedure that makes me replace the autocad point with a generic block containing a visible attribute.

I make a sempio: amount from an excel/txt file of the points with their geo coordinates referenced, the display on autocad is a series of points colocati according to x and y.
At this point I would like to replace them with a block called pl having a "cod" attribute visible.

Is that possible?
Thank you.
 
Code:
(defun c:p2b)
(setq gru (ssget '((0 . "point")))
index -1
)
(repeat)
(setq point (cdr (asc 10 (entget (ssname gru (setq index(1+ index))))))))
(command "_insert" "pl" point 1 1 0 "")
)
(command "_erase" gru ")
(principal)
)
 
(defun c:p2b. . .
:finger:


for tranquility, eye to osmode and attdia:
Code:
(defun c:p2b)
(Setq Attd (Generally "Attdia")
(setq os (getvar ‘osmode’)
(Atdia 0)
(Setvar "Osmode" 0)
(setq gru (ssget '(0.
Index -1
)
(Slength Gru)
(setq point (assoc 10)))
(command "_insert" "pl" point 1 0")
)
(command "_erase" mine")
(Atdia)
(Setvar “Osmode” os)
(Princ)
)
 
Of course! but with this we also manage errors, undo and instead of a few lines of code we make 200, leemac style! :biggrin::biggrin:

Yeah, I forgot. . .
in the lisp you can compact the whole...
Code:
(defun c:p2b()(setq attd(gether "attdia")os(getvar "osmode"))(setvar "attdia" 0)(setvar "osmode" 0)(setq gru(ssget '((0. "point"))))))index -1)(repeat(slength gru)(command "_insert" pl" (cdr(ssoci) 10(sent)(sname)(s))(s)(s)(s))(s))))(s))(s)))(s))))))(s))))(s)))(s)(s)))(s)))))(s)(s))(s))(s)))))(s)))))
See? with one single line of code we solved everything!:tongue::tongue:
 
I did the check but some points are erased and not replaced. do the points have a constraint? if together with the coordinates x and y amount "old code" and "new code" can I associate them with the new block that will replace the generated points?
 
points, belonging to the crane variable, are all deleted at the end with (command "_erase" crane "). There are no constraints, nor osnap, the program takes the coordinates it finds. the dwg we see.
 
you said that the block contained only one visible attribute and instead there were 6 invisible attributes. . .

(defun c:p2b ()
(setq attd)
(setq os (getvar "osmode")
(setvar "attdia" 0)
(Setvar "osmode" 0)
(setq crane (ssget '(0 . "point"))))
index -1
)
(repeat (sslength crane)
(setq point (cdr (assoc 10))))))
(command "_insert" "pl" point 1 0)
)
(command "_erase" crane")
(setvar "attdia" attd)
(setvar "osmode" os)
(princ)
)
 
It should be inserted, depending on the inserted block (how many attributes there are, whether they are visible or not, pre-assigned, etc...), conditions to avoid error messages. in this case it works.
 
small variant:
replace the line:(command "_insert" "pl" point 1 1 0 "")
con(entmake (list '(0 . "insert") '(2 . "pl") point))
 
was missing the cons a point...

(entmake (list '(0 . "insert") '(2 . "pl") (cons 10 point)))

if you do not have special requirements regarding the scale and angle of rotation the entmake function is much better than insert.
 
the last solution is that that sweeps away the various initial settings (and besides it is faster), but with attreq = 0 it was good also the first lisp.
 
I'm sorry, my little dimestic about the matter, but I lost something in your right observations.
I think I understand that:
if I have a table with x and y defined in a unique way;
if at every point I give a unique value
if at this point I associate other information of different nature .......
Can you do the following?
replace the classic autocad point with a precreated block with n attributes and associate them with the various info?
I don't believe it! magagari tell me you color the block with a different color according to a default variable on one of the attributes? Where have I been all this time?
I make an exemplary:
x = 10

unique cod =ab1234
cod old =1p
type lamp = sap (or hg or led or other)
I can see my block with the unique and colorful cod according to the type of lamp.
fantastic how incredulous I am.
They're good.
 
per confutatis, riguardo al cons.
scuses the fretta, dovevo laying the intero codice.

(setq pts (ssget "x" (list '(0 . "point"))))))
(sslength pts)
(setq p1 (assoc 10 (entget (ssname pts (setq and (1-i)))))))))
(entmake (list '(0 . "insert") '(2 . "pl") p1))
)
 
replace it entirely to the code I posted you the first time. as the "x" of ssget is used to select all the points that it finds, if you want to make a selection manually, in a very determined area, just write:
(setq pts (ssget (list '(0 . "point")))))
 
to andrea, which seems very interested in the topic, to supplement what has specified termin.., excuse, confutatis:

(ssget "_x") selects all the main objects of the database, even outside the screen, even places on deactivated and/or frozen floors.
However, there is an undocumented option of ssget:
(setq pts (ssget "_a))) that selects all the objects of the database (such as ssget "x"), except those located on frozen floors.

Hi.
 

Forum statistics

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

Members online

No members online now.
Back
Top