Jump to content

# Rounding all polylines from snap selection

## Recommended Posts

Rounding of 4 polylines according to the criteria:
- radii from inside 420 , 560, 588 , 728
- if the outer polyline becomes the inner then round 728,588 ,560, 420
The point is to detect with 4 polylines are next to each other, determine which is internal and which is external. Then for each polyline round the hatches alternately according to the above criteria.
Also i am looking for a way to sort polylines according to selection cords. Right now if i select every polylines clicking one by one its fillet according to selection but if i try to snap selection then its all messed up its going like 1-1 , 2-3  ,3 -4 , 4-2

```(defun c:changefillet ()
(setq ss (ssget '((0 . "LWPOLYLINE"))))

(setq num (sslength ss))
(if (= num 4)
(progn
(setq pl1 (ssname ss 0))
(setq pl2 (ssname ss 1))
(setq pl3 (ssname ss 2))
(setq pl4 (ssname ss 3))
(progn  ;lewo
(setvar "FILLETRAD" 420)
(command "_.fillet" "_polyline" pl1)
(setvar "FILLETRAD" 560)
(command "_.fillet" "_polyline" pl2)
(setvar "FILLETRAD" 588)
(command "_.fillet" "_polyline" pl3)
(setvar "FILLETRAD" 728)
(command "_.fillet" "_polyline" pl4)
)
)
)
(princ)
)```

Rn its look like that:

And i want to acheve this:

##### Share on other sites

Are the images back to front as offset would do what you want. Are you trying to convert offset plines to have different radius as per image 1.

##### Share on other sites

I want to convert offsets.
those are 4 seperate polylynes which i draw with code: (its modified code from someone from this topic)

```(defun offset-lines (ale /)
(setq offset-distance ale)
(if lines
(progn
(setq i 0)
(while (< i (sslength lines))
(setq sel (ssname lines i))
(command "odsuń" offset-distance sel basept "")
(setq i (1+ i))
)
(setq newobjs (ssget "_L"))

(if newobjs
(progn
(setvar "FILLETRAD" 0)
(repeat (setq n (sslength newobjs))
(command "_.fillet" "_polyline" (ssname newobjs (setq n (1- n))))
)
(princ "\nNo new objects created.")
)
)
(princ "\nNo lines selected.")
)
(princ)
)
)

(defun delaypoint ()
(initget "200 28 bez")
(setq chosenOption (getkword "\n odsunięcie o ile: [200/28/bez] <28>: "))
(cond
((equal chosenOption "200")
(progn
(setq lines (ssget '((0 . "LINE,ARC,LWPOLYLINE"))))
(setq basept (getpoint "\nSelect base point: "))
(offset-lines "270")
)
)
((equal chosenOption "28")
(progn
(setq lines (ssget '((0 . "LINE,ARC,LWPOLYLINE"))))
(setq basept (getpoint "\nSelect base point: "))
(offset-lines "98")
)
)
((equal chosenOption "bez"))
)
(princ)
)
(defun c:dpipe (/ oldWd oldFil oldEch lEnt pl1 pl2 vLst1 vLst2 *error*)
(vl-load-com)
(delaypoint)
(defun GetPlineVer (plObj)
(mapcar 'cdr
(vl-remove-if-not
'(lambda (x) (= (car x) 10))
(entget plObj)
)
)
) ; end of GetPLineVer

(defun *error* (msg)
(setvar "CMDECHO" oldEch)
(setvar "FILLMODE" oldFil)
(princ)
) ; end of *error*

(setq duct:pWd 140.0)
(setq oldFil (getvar "FILLMODE")
oldEch (getvar "CMDECHO")
) ; end setq
(mapcar 'setvar
'("CMDECHO" "FILLMODE")
'(0 0)
)
(if (entlast) (setq lEnt (entlast)))
(princ "\nSpesify start point: ")
(command "_.pline" pause)
(command "_w" duct:pWd duct:pWd)
(while (= 1 (getvar "CMDACTIVE"))
(command pause)
(princ "\nSpecify next point: ")
) ; end while
(if
(not
(equal lEnt (entlast))
)
(progn
(setq promien "420")
(setq promien2 (+ (atoi promien) 70))
(setq lEnt (entlast))
(command "_.fillet" "_r" promien2)
(command "_.fillet" "_p" lEnt)
(setq lEnt  (vlax-ename->vla-object lEnt)
pl1   (car
(vlax-safearray->list
(vlax-variant-value
(vla-Offset lEnt (/ duct:pWd 2))
)
)
)
pl2   (car
(vlax-safearray->list
(vlax-variant-value
(vla-Offset lEnt (- (/ duct:pWd 2)))
)
)
)
vLst1 (GetPlineVer
(vlax-vla-object->ename pl1)
)
vLst2 (GetPlineVer
(vlax-vla-object->ename pl2)
)
) ; end setq
(vla-put-ConstantWidth pl1 0.0)
(vla-put-ConstantWidth pl2 0.0)
(vla-Delete lEnt)
) ; end progn
) ; end if
(setvar "CMDECHO" oldEch)
(setvar "FILLMODE" oldFil)
(princ)
) ; end ```

Offsetlines together with delaypoint is used for creating "support lines" to draw another pipes according to my preferences
The given code is written in the AutoLISP programming language and contains a function called "dpipe". The purpose of this function is to create a duct-shaped polyline with rounded corners based on user input. For those offset thing i set filletrad to 0 to make it easier to draw pipes next to eachother

The function begins by loading the AutoLISP COM library and calling another function called "delaypoint". This function prompts the user to enter an offset distance for the polyline and selects lines, arcs, and lightweight polylines to be used as a base for the duct. It then calls the "offset-lines" function to offset the selected objects by the specified distance.

After the offsetting is done, the function creates fillets on the corners of the polyline and sets the "FILLETRAD" variable to 0 to ensure that the fillets are created without any radius. The resulting polyline is stored in the "newobjs" variable.

The next part of the code defines two helper functions: "GetPlineVer" and "error". The "GetPlineVer" function extracts the vertices of a polyline as a list of 2D points. The "error" function is used to handle any errors that might occur during the execution of the main function.

The code then sets some variables and prompts the user to specify the start point of the polyline. It then enters a loop where the user is prompted to specify the next point until they exit the command.

If the user successfully creates the polyline, the code uses the "entlast" function to get the entity name of the last object created and stores it in the "lEnt" variable. The code then applies fillets to the corners of the polyline and deletes the original polyline. Finally, the "CMDECHO" and "FILLMODE" variables are reset to their original values.

Overall, this function provides a simple way to create duct-shaped polylines with rounded corners in AutoCAD using AutoLISP.

##### Share on other sites

Pretty sure that Tharwat has a ducting program and that it will do what you want, do a Google.

##### Share on other sites

not exactly what i want but interesting concept thanks.

## 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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
×
• Create New...