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

lisp to convert polylinea in double closed line with dashed insert

  • Thread starter Thread starter brizzo1982
  • Start date Start date

brizzo1982

Guest
Good morning, everyone.
I would need a function that allows to convert selected polylines with a globable width defined in a closed double line (determined by the same width of the polylinea), with automatically inserted a defined dash.
brilliant idea to draw cable ducts quickly: instead of handing the double lines, collecting them, inserting the all-hand restraints, you could quickly draw the polylinee with width identical to the size of the channel, and then throw the lisp into object to turn it into an aesthetically pleasing channel if compared to the full polyline! :biggrin:

..unfortunately my acquaintances of the autolisp are limited..if someone comes forward I offer a coffee paid at the forum bar!

Thank you in advance. :finger:
 
Code:
(defun c:pl2can)
(setq gru(ssget '(0 . "lwpolyline"))))
index -1
modelspace(vla-get-modelspace (vla-get-activedocument(vlax-get-acad-object))))
)
(setvar "hpname" "ansi31")
(setvar "hpscale" 4)
(repeat (sslength gru)
(setq spessore(vla-get-constantwidth (vlax-ename->vla-object (ssname gru (setq index(1+ index))))))))
(vla-put-constantwidth (vlax-ename->vla-object (ssname gru index) 0.0)
(setq ent1(car(vlax-safearray->list (vlax-variant-value))))
(setq ent2(car(vlax-safearray->list (vlax-variant-value))))
(setq coord1 (variant2list (vla-get-coordinates ent1) 2))
(setq coord2 (variant2list (vla-get-coordinates ent2))
(vla-addline modelspace (vlax-3d-point (car coord1))
(vl-cmdf "_pedit" (entlast) "_j" (vlax-vla-object->ename ent1)(vlax-vla-object->ename ent2) ""_cl" "")
(vl-cmdf "_hatch" """" (entlast)
)
)

;; ***************************funzione variant2lista***************************
;; transforms a variant in a lista a gruppi con numero elementi per gruppo
(defun variant2lista (listavariant numero / listaparz listafin)
(setq listaparz '()
listafin '()
)
(foreach elemento (vlax-safearray->list)
(setq listaparz (append listaparz))
(if (= (length listaparz) numero)
(setq listafin (append listafin (list listaparz)))
listaparz '()
)
)
)
Listafin
)
 
Confutatis solution is beautiful, but have you ever tried to use multilines?
in addition to drawing the routes as simple lines, you can insert the nets that, being associative, moving the vertices of the multiline automatically retrace avoiding having to remake everything.

bye
 
@brick

If you have to convert existing polylines, my programme goes well, if not the solution of rpor66 is certainly more rational.
 
multilines are more manageable in case of change, but the lisp of confutatis (*) also allows to treat the arches of the poly, depends on the use that has to make brizzo.


(*) as usual tightened and resolute :finger:, you could launch a assist to such knows1cooper :biggrin:
 
beautiful would also be the reverse operation, from double poly to poly with thickness and would allow more immediate changes.
 
thanks to everyone for the interest!
confutatis, the lisp you kindly signaled creates me a double line but instead of the internal restraint brings me a single pl..where wrong?
..I repeat my extraneity to autolisp language, dictated by the lack of time to devote x learning. .

As for the double lines yes, frankly I had not thought about it, but I find some difficulties: malmanagement of the osnap, unclosed lines, impossibility to connect them with arches...do I say well or miss something?


..kentcooper I did not know him..I know of a devout luminaire to the resolution of the problems of auto-lispian humanity!! :-)
 
In the meantime, you should change the scale.
you have to change the line (setvar "hpscale" 4) and change the number according to your needs.
You'll see how by magic is the same lisp that created Mr. Cooper... (with some very small variation) :biggrin:

the inner polylinea has not been erased, but it is a thing wanted: you can put it in a hidden layer and reuse it if you have to perform the reverse operation
 
In the meantime, you should change the scale.
you have to change the line (setvar "hpscale" 4) and change the number according to your needs.
You'll see how by magic is the same lisp that created Mr. Cooper... (with some very small variation) :biggrin:

the inner polylinea has not been erased, but it is a thing wanted: you can put it in a hidden layer and reuse it if you have to perform the reverse operation
...:Mad: why can't I?!? ! ?
..I changed scale from one 0.1 to 10...all the times the function returns me

command: pl2can
select objects: found(s) 1
select objects:
_pedit select polylinea or [Polilinee]:
the selected object is not a polylinea
you want to turn it into polylinea? <s> _
Yes or no, please.
you want to turn it into polylinea? <s> select polylinea or </s></s>[Polilinee]:
type an option [Apri/Unisci/Larghezza/Edita
vertici/ADatta/Spline/Rettifica/Tipolinea gen./Inverti/ANnulla]:
command: _cl command unknown "cl". press f1 for the guide.
command: pl2can command unknown "pl2can". press f1 for the guide.
command: _
type a model name or [?/Solido/Definito utente] <ansi31>:
specify a scale for the model <0.0100>:
specify an angle for the model <0>: select objects to define the
contour of restraint or <tratteggio diretto="">,
select objects: found(s) 1
select objects:
impossible to treat the contour.
command: ?
command:
command: *nullato*


:confused:</tratteggio></ansi31>
 
..nothing to do.. :frown:

command: pl2can
select objects: found(s) 1
select objects:
_pedit select polylinea or [Polilinee]:
type an option [CHiudi/Unisci/Larghezza/Edita
vertici/ADatta/Spline/Rettifica/Tipolinea gen./Inverti/ANnulla]_j
select objects: found(s) 1
select objects: found(s) 1, 2 total
select objects:
0 segments added to polylinea
type an option [CHiudi/Unisci/Larghezza/Edita
vertici/ADatta/Spline/Rettifica/Tipolinea gen./Inverti/ANnulla]_cl
type an option [Apri/Unisci/Larghezza/Edita
vertici/ADatta/Spline/Rettifica/Tipolinea gen./Inverti/ANnulla]:
command: _
type a model name or [?/Solido/Definito utente] <ansi31>:
specify a scale for the model <0.1000>:
specify an angle for the model <0>: select objects to define the
contour of restraint or <tratteggio diretto="">,
select objects: found(s) 1
select objects:
impossible to treat the contour.
command: ?</tratteggio></ansi31>
 
I don't know what to say, it works to me but I don't know if other forum users have tried it too. the question of the scale could stand, peditaccept had to go to 1, but I see that it does not add segments to the new polyline obtained.
at this point try to send a piece of design that we see. . .
 
I don't know what to say, it works to me but I don't know if other forum users have tried it too. the question of the scale could stand, peditaccept had to go to 1, but I see that it does not add segments to the new polyline obtained.
at this point try to send a piece of design that we see. . .
Here we go.
on the left <prima>, to the right the <dopo> pl2can.

Thank you.</dopo></prima>
 

Attachments

you never consider all possible cases. open or closed polylines.. .
Code:
(defun c:pl2can)
(setvar "peditaccept" 1)
(setvar "cmdecho" 1)
(setq gru(ssget '(0 . "lwpolyline"))))
index -1
modelspace(vla-get-modelspace (vla-get-activedocument(vlax-get-acad-object))))
)
(setvar "hpname" "ansi31")
(setvar "hpscale" 1)
(repeat (sslength gru)
(setq spessore(vla-get-constantwidth (vlax-ename->vla-object (ssname gru (setq index(1+ index))))))))
(vla-put-constantwidth (vlax-ename->vla-object (ssname gru index) 0.0)
(setq ent1(car(vlax-safearray->list (vlax-variant-value))))
(setq ent2(car(vlax-safearray->list (vlax-variant-value))))
(setq coord1 (variant2list (vla-get-coordinates ent1) 2))
(setq coord2 (variant2list (vla-get-coordinates ent2))
(cond)
(eq (vla-get-closed ent1) :vlax-true)
(vl-cmdf "_hatch" """" (vlax-vla-object->ename ent1)(vlax-vla-object->ename ent2) "")
)
(eq (vla-get-closed ent1) :vlax-false)
(vla-addline modelspace (vlax-3d-point (car coord1))
(vl-cmdf "_pedit" (entlast) "_j" (vlax-vla-object->ename ent1)(vlax-vla-object->ename ent2) ""_cl" "")
(vl-cmdf "_hatch" """" (entlast)
)
)
)
)

;; ***************************funzione variant2lista***************************
;; transforms a variant in a lista a gruppi con numero elementi per gruppo
(defun variant2lista (listavariant numero / listaparz listafin)
(setq listaparz '()
listafin '()
)
(foreach elemento (vlax-safearray->list)
(setq listaparz (append listaparz))
(if (= (length listaparz) numero)
(setq listafin (append listafin (list listaparz)))
listaparz '()
)
)
)
Listafin
)
 
you never consider all possible cases. open or closed polylines.. .
Code:
(defun c:pl2can)
(setvar "peditaccept" 1)
(setvar "cmdecho" 1)
(setq gru(ssget '(0 . "lwpolyline"))))
index -1
modelspace(vla-get-modelspace (vla-get-activedocument(vlax-get-acad-object))))
)
(setvar "hpname" "ansi31")
(setvar "hpscale" 1)
(repeat (sslength gru)
(setq spessore(vla-get-constantwidth (vlax-ename->vla-object (ssname gru (setq index(1+ index))))))))
(vla-put-constantwidth (vlax-ename->vla-object (ssname gru index) 0.0)
(setq ent1(car(vlax-safearray->list (vlax-variant-value))))
(setq ent2(car(vlax-safearray->list (vlax-variant-value))))
(setq coord1 (variant2list (vla-get-coordinates ent1) 2))
(setq coord2 (variant2list (vla-get-coordinates ent2))
(cond)
(eq (vla-get-closed ent1) :vlax-true)
(vl-cmdf "_hatch" """" (vlax-vla-object->ename ent1)(vlax-vla-object->ename ent2) "")
)
(eq (vla-get-closed ent1) :vlax-false)
(vla-addline modelspace (vlax-3d-point (car coord1))
(vl-cmdf "_pedit" (entlast) "_j" (vlax-vla-object->ename ent1)(vlax-vla-object->ename ent2) ""_cl" "")
(vl-cmdf "_hatch" """" (entlast)
)
)
)
)

;; ***************************funzione variant2lista***************************
;; transforms a variant in a lista a gruppi con numero elementi per gruppo
(defun variant2lista (listavariant numero / listaparz listafin)
(setq listaparz '()
listafin '()
)
(foreach elemento (vlax-safearray->list)
(setq listaparz (append listaparz))
(if (= (length listaparz) numero)
(setq listafin (append listafin (list listaparz)))
listaparz '()
)
)
)
Listafin
)
Yeah, it's working now! :finger:
Perfect! the only thing would be to have the restraint associated with the closed polylinea, so that any changes also affect the hatch.. and the direct shift of the median polyline on a dedicated layer called 01_polilinee_nascoste. . .
But I don't want to abuse your kindness and patience, so that's okay!
Thank you! :biggrin:

coffee paid at the bar as promised! :smile:
 
Actually there would be a way to make it associated with activex methods, but it is very slender. I will write this function one day. . .
 
behind suggestions of gp (thank you), instead of :
(vl-cmdf "_hatch" """" (entlast) ")

replaces with:
(vl-cmdf "_-hatch" "_s" (entlast) "_a" "_a" "_y" """)

In this way more options come out including the association.
the whole is born from having wanted to use at all costs the multilanguage with (vl-cmdf "_hatch" ...), instead of (vl-cmdf "-trate"...). Just run:
(vl-cmdf "_-hatch". ..
 
I also am not very practical of lisp, and so it happens that I take advantage of the tips / suggestions of this forum.
any of you can confirm me if the previously mentioned lisp to convert polylinea with polylinea thickness in double line closed with insert hold is valid only for polylinee with constant thickness? as I'm trying, but it only works when the polylinea has constant thickness... where is it wrong?
Thank you very much
Marco fabbri
 
I also am not very practical of lisp, and so it happens that I take advantage of the tips / suggestions of this forum.
any of you can confirm me if the previously mentioned lisp to convert polylinea with polylinea thickness in double line closed with insert hold is valid only for polylinee with constant thickness? as I'm trying, but it only works when the polylinea has constant thickness... where is it wrong?
Thank you very much
Marco fabbri
even to me it only works when the width of the polyline is constant.

Hi.
 
Thank you.
So someone can tell me if there is a lisp to turn a polylinea with non-consistent thickness into a closed polylinea? then if it generated even a retino automatically would be the maximum.. .
Thank you very much
Marco fabbri
 

Forum statistics

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

Members online

No members online now.
Back
Top