Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Continuous Offset with last entity & diff dist...

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
627 Views, 11 Replies

Continuous Offset with last entity & diff dist...

I am trying to write a lisp routine that will offset a line then
automatically select the new line and ask for a new distance.

It is not working like I thought it would... Any Help / suggestions?

Here is what I have:

(defun c:mul (/)
(setq myent (entsel))
(command "offset" pause myent pause "")
(setq newent (entget (entlast)))
(while (/= newent nil)
(command "offset" pause newent pause "")
(setq newent (entget (entlast)))
)
)


Thanks
Rick
11 REPLIES 11
Message 2 of 12
t.willey
in reply to: Anonymous

(defun c:mul (/ myent)
(setq myent (entsel))
(command "offset" pause myent pause "")
(setq newent (entlast))
(while (/= newent nil)
(command "offset" pause newent pause "")
(setq newent (entlast))
)
)


Took out the entget before the entlast, not needed (two places). The way it works now you will have to cancel it with and escape key.

Tim
Message 3 of 12
Anonymous
in reply to: Anonymous

Thanks..

I knew it couldnt be that hard, Its nice to know I was closer than I
thought.

Rick


wrote in message news:4883463@discussion.autodesk.com...
(defun c:mul (/ myent)
(setq myent (entsel))
(command "offset" pause myent pause "")
(setq newent (entlast))
(while (/= newent nil)
(command "offset" pause newent pause "")
(setq newent (entlast))
)
)


Took out the entget before the entlast, not needed (two places). The way it
works now you will have to cancel it with and escape key.

Tim
Message 4 of 12
t.willey
in reply to: Anonymous

You're welcome. Happy to help when I can.

Tim
Message 5 of 12
Anonymous
in reply to: Anonymous

This may also help. Hopefully I included all the sub routines.

; mvo multi variable offset BY ALEX KONIECZKA
(defun c:mvo ()
(print "Select object to offset: ")(gent)
(setq tpt entpt tpt1 (getpoint "Select side to offset: ") dd 0 tang (angle
entpt tpt1))


(while (setq d (getstring "Enter an offset value (*# for multiple) :"))

(if (= "*" (substr d 1 1))
(progn (setq n (atoi (substr d 2)) d (getstring "Distance: : ") d (atof
) ))
(progn (setq n 1 d (atof d) ))
) ;if

(repeat n (progn

(SETQ DD (+ DD D) tpt (polar tpt tang dd) )
(command "offset" d entn tpt "")(gents (entlast))
))

); while
(princ) )


; offset from base pick a base point and hold the cursor on the side you
want to offset and start typing #'s

(defun c:ob ()
(print "Select base object to offset from and put currsor on the offset
side, then type numbers: ")(gent)
(while (setq d (getstring "Enter an offset value (*# for multiple) :"))
(setq tpt1 (cadr (grread 1)))
(setq tpt entpt dd 0 tang (angle entpt tpt1))
(command "offset" d entn tpt1 "")
); while
(princ) )

; ot offset through will change layer to the picked item.
(defun c:ot ()
(print "Select base object to offset: ")(gent)(setq e (car entn))
(while (gent)
(setq layn (ass 😎 tpt1 entpt)
(command "offset" "t" e tpt1 "")
(gents (entlast))(modent 8 layn)
); while
(princ) )



; dof = double offset to current layer

(defun c:dof ()
(setq d (getval d "Enter doffset: "))
(while (print "Select line to offset: ")(gent)
(if (= (ass 0) "LINE")(progn
(setq e entn tpt1 (polar (ass 10) (+ (angle (ass 10) (ass 11)) (/ pi 2))
1) tpt2 (polar (ass 10) (+ (angle (ass 10) (ass 11)) (/ pi -2)) 1) )
(command "offset" d e tpt1 "")(gents (entlast))(modent 8 (getvar
"clayer"))
(command "offset" d e tpt2 "")(gents (entlast))(modent 8 (getvar
"clayer"))
)))
(princ))

; gent returns the entity name of the item picked
(defun gent ()
(setq entn (entsel))
(setq entcodes (entget (car entn)))
(setq entpt (cadr entn))
(setq entt (cdr (assoc 0 entcodes)))
)

; ass returns the (cdr (assoc n)) of the the item. (ass 10) => (10 . 1 2 3)
(defun ass (code / )
(cdr (assoc code entcodes))
)

; gents returns the entity name of the item passed to it from a selction set
(defun gents (entname /)
(setq entn entname entcodes (entget entn) entpt nil)
(setq entt (cdr (assoc 0 entcodes)))
(princ))




"Rick Keller" wrote in message
news:4883417@discussion.autodesk.com...
I am trying to write a lisp routine that will offset a line then
automatically select the new line and ask for a new distance.

It is not working like I thought it would... Any Help / suggestions?

Here is what I have:

(defun c:mul (/)
(setq myent (entsel))
(command "offset" pause myent pause "")
(setq newent (entget (entlast)))
(while (/= newent nil)
(command "offset" pause newent pause "")
(setq newent (entget (entlast)))
)
)


Thanks
Rick
Message 6 of 12
Anonymous
in reply to: Anonymous

[Not in response to the latest message from Alex, but to the original post,
which I didn't keep to reply to directly....]

If you're really talking about Lines (and Xlines and Rays) ONLY, here's
another approach that would work:

Ask the user to select the Line, and from its association list, rotate
SNAPANG to align with its endpoints (assoc 10 & 11). Turn ortho on and ask
to which side to "offset" it, and save that angle. (Then you can set
SNAPANG back where it was, and turn ortho off.) Then ask for the first
"offset" distance, and Copy that selected Line at the saved angle and the
given distance. Ask for the next distance, and do a "while" loop: as long
as the user keeps giving a new distance, Copy the Last item, again at the
saved angle and the latest given distance. (That's why I put "offset" in
quotes earlier -- it's not really doing it by offsetting.)

This AVOIDS the "problem" that Offset wants object selection to be by a
point (you can't use Last with Offset, as you can with Copy).

It wouldn't work as Offset does with Circles, Arcs, most Polylines, etc.,
but would be exactly equivalent with Lines, Xlines, Rays, and
single-line-segment Polylines.
--
Kent Cooper


"Rick Keller" wrote...
I am trying to write a lisp routine that will offset a line then
automatically select the new line and ask for a new distance.

It is not working like I thought it would... Any Help / suggestions?

Here is what I have:

(defun c:mul (/)
(setq myent (entsel))
(command "offset" pause myent pause "")
(setq newent (entget (entlast)))
(while (/= newent nil)
(command "offset" pause newent pause "")
(setq newent (entget (entlast)))
)
)


Thanks
Rick
Message 7 of 12
Anonymous
in reply to: Anonymous

Yes Alex that is exactly what I was driving for (mvo).

Thanks for the code. What I had was working but I was going to refine it to
work
just like yours does.

Thanks again.
Rick


"Alex" wrote in message
news:4884360@discussion.autodesk.com...
This may also help. Hopefully I included all the sub routines.

; mvo multi variable offset BY ALEX KONIECZKA
(defun c:mvo ()
(print "Select object to offset: ")(gent)
(setq tpt entpt tpt1 (getpoint "Select side to offset: ") dd 0 tang (angle
entpt tpt1))


(while (setq d (getstring "Enter an offset value (*# for multiple) :"))

(if (= "*" (substr d 1 1))
(progn (setq n (atoi (substr d 2)) d (getstring "Distance: : ") d (atof
) ))
(progn (setq n 1 d (atof d) ))
) ;if

(repeat n (progn

(SETQ DD (+ DD D) tpt (polar tpt tang dd) )
(command "offset" d entn tpt "")(gents (entlast))
))

); while
(princ) )


; offset from base pick a base point and hold the cursor on the side you
want to offset and start typing #'s

(defun c:ob ()
(print "Select base object to offset from and put currsor on the offset
side, then type numbers: ")(gent)
(while (setq d (getstring "Enter an offset value (*# for multiple) :"))
(setq tpt1 (cadr (grread 1)))
(setq tpt entpt dd 0 tang (angle entpt tpt1))
(command "offset" d entn tpt1 "")
); while
(princ) )

; ot offset through will change layer to the picked item.
(defun c:ot ()
(print "Select base object to offset: ")(gent)(setq e (car entn))
(while (gent)
(setq layn (ass 😎 tpt1 entpt)
(command "offset" "t" e tpt1 "")
(gents (entlast))(modent 8 layn)
); while
(princ) )



; dof = double offset to current layer

(defun c:dof ()
(setq d (getval d "Enter doffset: "))
(while (print "Select line to offset: ")(gent)
(if (= (ass 0) "LINE")(progn
(setq e entn tpt1 (polar (ass 10) (+ (angle (ass 10) (ass 11)) (/ pi 2))
1) tpt2 (polar (ass 10) (+ (angle (ass 10) (ass 11)) (/ pi -2)) 1) )
(command "offset" d e tpt1 "")(gents (entlast))(modent 8 (getvar
"clayer"))
(command "offset" d e tpt2 "")(gents (entlast))(modent 8 (getvar
"clayer"))
)))
(princ))

; gent returns the entity name of the item picked
(defun gent ()
(setq entn (entsel))
(setq entcodes (entget (car entn)))
(setq entpt (cadr entn))
(setq entt (cdr (assoc 0 entcodes)))
)

; ass returns the (cdr (assoc n)) of the the item. (ass 10) => (10 . 1 2 3)
(defun ass (code / )
(cdr (assoc code entcodes))
)

; gents returns the entity name of the item passed to it from a selction set
(defun gents (entname /)
(setq entn entname entcodes (entget entn) entpt nil)
(setq entt (cdr (assoc 0 entcodes)))
(princ))




"Rick Keller" wrote in message
news:4883417@discussion.autodesk.com...
I am trying to write a lisp routine that will offset a line then
automatically select the new line and ask for a new distance.

It is not working like I thought it would... Any Help / suggestions?

Here is what I have:

(defun c:mul (/)
(setq myent (entsel))
(command "offset" pause myent pause "")
(setq newent (entget (entlast)))
(while (/= newent nil)
(command "offset" pause newent pause "")
(setq newent (entget (entlast)))
)
)


Thanks
Rick
Message 8 of 12
Anonymous
in reply to: Anonymous

Thanks,

That is another way of solving the problem.

I am usually only copying/offsetting lines mostly gridlines for buildings.

The truth is I only need something simple but thanks for the different view
on the problem.

I was wondering how I could mimic offsetting to a side like AutoCAD does.

Rick



"Kent Cooper" wrote in message
news:4884420@discussion.autodesk.com...
[Not in response to the latest message from Alex, but to the original post,
which I didn't keep to reply to directly....]

If you're really talking about Lines (and Xlines and Rays) ONLY, here's
another approach that would work:

Ask the user to select the Line, and from its association list, rotate
SNAPANG to align with its endpoints (assoc 10 & 11). Turn ortho on and ask
to which side to "offset" it, and save that angle. (Then you can set
SNAPANG back where it was, and turn ortho off.) Then ask for the first
"offset" distance, and Copy that selected Line at the saved angle and the
given distance. Ask for the next distance, and do a "while" loop: as long
as the user keeps giving a new distance, Copy the Last item, again at the
saved angle and the latest given distance. (That's why I put "offset" in
quotes earlier -- it's not really doing it by offsetting.)

This AVOIDS the "problem" that Offset wants object selection to be by a
point (you can't use Last with Offset, as you can with Copy).

It wouldn't work as Offset does with Circles, Arcs, most Polylines, etc.,
but would be exactly equivalent with Lines, Xlines, Rays, and
single-line-segment Polylines.
--
Kent Cooper


"Rick Keller" wrote...
I am trying to write a lisp routine that will offset a line then
automatically select the new line and ask for a new distance.

It is not working like I thought it would... Any Help / suggestions?

Here is what I have:

(defun c:mul (/)
(setq myent (entsel))
(command "offset" pause myent pause "")
(setq newent (entget (entlast)))
(while (/= newent nil)
(command "offset" pause newent pause "")
(setq newent (entget (entlast)))
)
)


Thanks
Rick
Message 9 of 12
Anonymous
in reply to: Anonymous

glad to be of help. coming up with new and fatser ways to do things is a
lot of fun.


"Rick Keller" wrote in message
news:4884478@discussion.autodesk.com...
Yes Alex that is exactly what I was driving for (mvo).

Thanks for the code. What I had was working but I was going to refine it to
work
just like yours does.

Thanks again.
Rick


"Alex" wrote in message
news:4884360@discussion.autodesk.com...
This may also help. Hopefully I included all the sub routines.

; mvo multi variable offset BY ALEX KONIECZKA
(defun c:mvo ()
(print "Select object to offset: ")(gent)
(setq tpt entpt tpt1 (getpoint "Select side to offset: ") dd 0 tang (angle
entpt tpt1))


(while (setq d (getstring "Enter an offset value (*# for multiple) :"))

(if (= "*" (substr d 1 1))
(progn (setq n (atoi (substr d 2)) d (getstring "Distance: : ") d (atof
) ))
(progn (setq n 1 d (atof d) ))
) ;if

(repeat n (progn

(SETQ DD (+ DD D) tpt (polar tpt tang dd) )
(command "offset" d entn tpt "")(gents (entlast))
))

); while
(princ) )


; offset from base pick a base point and hold the cursor on the side you
want to offset and start typing #'s

(defun c:ob ()
(print "Select base object to offset from and put currsor on the offset
side, then type numbers: ")(gent)
(while (setq d (getstring "Enter an offset value (*# for multiple) :"))
(setq tpt1 (cadr (grread 1)))
(setq tpt entpt dd 0 tang (angle entpt tpt1))
(command "offset" d entn tpt1 "")
); while
(princ) )

; ot offset through will change layer to the picked item.
(defun c:ot ()
(print "Select base object to offset: ")(gent)(setq e (car entn))
(while (gent)
(setq layn (ass 😎 tpt1 entpt)
(command "offset" "t" e tpt1 "")
(gents (entlast))(modent 8 layn)
); while
(princ) )



; dof = double offset to current layer

(defun c:dof ()
(setq d (getval d "Enter doffset: "))
(while (print "Select line to offset: ")(gent)
(if (= (ass 0) "LINE")(progn
(setq e entn tpt1 (polar (ass 10) (+ (angle (ass 10) (ass 11)) (/ pi 2))
1) tpt2 (polar (ass 10) (+ (angle (ass 10) (ass 11)) (/ pi -2)) 1) )
(command "offset" d e tpt1 "")(gents (entlast))(modent 8 (getvar
"clayer"))
(command "offset" d e tpt2 "")(gents (entlast))(modent 8 (getvar
"clayer"))
)))
(princ))

; gent returns the entity name of the item picked
(defun gent ()
(setq entn (entsel))
(setq entcodes (entget (car entn)))
(setq entpt (cadr entn))
(setq entt (cdr (assoc 0 entcodes)))
)

; ass returns the (cdr (assoc n)) of the the item. (ass 10) => (10 . 1 2 3)
(defun ass (code / )
(cdr (assoc code entcodes))
)

; gents returns the entity name of the item passed to it from a selction set
(defun gents (entname /)
(setq entn entname entcodes (entget entn) entpt nil)
(setq entt (cdr (assoc 0 entcodes)))
(princ))




"Rick Keller" wrote in message
news:4883417@discussion.autodesk.com...
I am trying to write a lisp routine that will offset a line then
automatically select the new line and ask for a new distance.

It is not working like I thought it would... Any Help / suggestions?

Here is what I have:

(defun c:mul (/)
(setq myent (entsel))
(command "offset" pause myent pause "")
(setq newent (entget (entlast)))
(while (/= newent nil)
(command "offset" pause newent pause "")
(setq newent (entget (entlast)))
)
)


Thanks
Rick
Message 10 of 12
vinodhkumar
in reply to: Anonymous

i want continuous doubleoffset with last entity in c#.net.please give logic

Message 11 of 12
Kent1Cooper
in reply to: vinodhkumar


@vinodhkumar wrote:

i want continuous doubleoffset with last entity in c#.net.please give logic


I can't help with c#.net, but I'm wondering: what does "continuous doubleoffset with last entity" really mean?  I can understand a continuous Offset command with the last entity automatically selected to be Offset again, as in the OP here.  But if you are doing a double Offset [assuming that you mean Offset to both sides], then the last entity will be one of the two entities resulting from that double Offset, and depending on how it's done, you may not have any control over which one that is, so automatically selecting it for the next double Offset may not get you the one you want.  Or am I misunderstanding what you want to do?

Kent Cooper, AIA
Message 12 of 12
vinodhkumar
in reply to: Kent1Cooper

thanks for reply.with my logic i am getting both sides offset of polyline with selected offset distance.my requirement is that doubleiffset continuous when i press anywhere in the location till i press ESC key.i am sending my written logic.

please send logic quickly .more thanks.............

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost