Xline in offset

Xline in offset

Anonymous
Not applicable
1,553 Views
7 Replies
Message 1 of 8

Xline in offset

Anonymous
Not applicable

Hi everyone,

 

I have this lisp: by entering a distance and picking a line it creates Xline in the specified distance and parallel to the selected line.

and I want it to work also if I pick a line in a block, can someone help with that?

 

(defun c:demo ( / offsetlobject otype ent odist ppt parm pts)
(command "_UCS" "_World" "")
(if
(and
(setq odist (getdist "\nEnter offset distance"))
(setq offsetlobject
(entsel
"\nSelect object to offset"))
(member (setq otype (cdr (assoc 0
(setq ent (entget (Car offsetlobject))))))
'("LWPOLYLINE" "LINE"))
)
(progn
(setq ppt (vlax-curve-getclosestpointto
(Setq e (car offsetlobject))
(cadr offsetlobject))
parm (vlax-curve-getParamAtPoint e ppt))
(setq pts
(if (eq otype "LINE")
(mapcar '(lambda (dxf)
(cdr (assoc dxf ent)))
'(10 11))
(mapcar '(lambda (v)
(vlax-curve-getPointAtParam e v))
(list (fix parm) (1+ (fix parm))))
)
)
(command "_Xline" "_non" (Car pts) "_non" (cadr pts) "")
(command "_.offset" "_Erase" "_Yes" odist ppt pause "")
(command "_UCS" "_V")
)
)
)

Thanks.

0 Likes
Accepted solutions (1)
1,554 Views
7 Replies
Replies (7)
Message 2 of 8

_gile
Consultant
Consultant

Hi,

 

Did you try just replacing (entsel with (nentsel (line #7)?



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 8

john.uhden
Mentor
Mentor

That's a start, but he'll probably need some coordinate transformations as well.  My XOFFSET function grew a lot bigger than I had originally anticipated, but I also included options for a whole polyline or just a segment and of course choices for layer, color, elevation, etc.

John F. Uhden

0 Likes
Message 4 of 8

Anonymous
Not applicable

Thanks, but it doesn't work.

When I click on a line in a block, it says: Cannot offset that object.

0 Likes
Message 5 of 8

john.uhden
Mentor
Mentor

That's because your program actually has to recreate the object in the current drawing and then it can be offset.

John F. Uhden

0 Likes
Message 6 of 8

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

... I want it to work also if I pick a line in a block, can someone help with that? ....


How 'bout this?  I took parts from my Bisector.lsp routine that allows various straight kinds of things and limits it to those, and a little from elsewhere, and hobbled together OffsetToXline.lsp with its OX command [attached].

 

Compared to the "demo" command posted, even if enhanced to work with nested Lines, OX has these advantages:

 

It doesn't do it from just Lines, Polylines and [as requested above] Lines that are nested in Blocks, but also from scads of other straight things, such as Rays, other Xlines, parts of Hatch patterns, straight-line parts [only] of Leaders and Dimensions and 3D Solids and Regions, edges of Viewports, Tolerance Boxes, 2D Solids, 3D Faces, Traces and Wipeouts, and  any of those nested in Blocks.  [I wanted to include the linear parts of Tables, but they yield incorrect results because of where MID and END Osnaps "land" on them.]

 

It doesn't give up on you if you pick on some inappropriate object, but asks again.

 

It forbids selection of a Polyline or Region or 3D Solid on an arc segment.

 

It allows the Through option of regular Offset, and displays the current setting [whether Through or a specified distance] and allows Enter/space to accept that as default.

 

It highlights  the initial Xline while in the Offset command, as a visual clue, since neither the OX nor the demo command "drags" the Offsetting operation from within a (command) function, as regular Offset does.

Kent Cooper, AIA
Message 7 of 8

Anonymous
Not applicable

Thank you very much @Kent1Cooper , that is exactly what I wanted.

 

Good day.

 

Eyal

 

0 Likes
Message 8 of 8

artmitchell51
Explorer
Explorer

I know this is old but THANK YOU! I've been looking for something like this!

0 Likes