|
Welcome, Guest.
|
||||||
| AutoLISP AutoLISP or Visual LISP, learn both here! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
All AUGI, all the time
Join Date: 2003-04
Location: Bethlehem, PA
Posts: 967
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Is there is a lisp routine that is similar to offset. You have a line for a center line and you want to have a lines on each side of it. So you pick the center line just like offset and you indicate what is the distance between the center line. And when you enter the value and hit enter. You have a line, a center line and a line.
Also you could pick the center line and after you do everything from the above idea. The center line the is erased. with this one you would have a line, a space and a line. Thank you, Brad |
|
|
|
|
|
#2 |
|
Administrator
Join Date: 2001-08
Location: Seattle WA US
Posts: 4,393
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
There might be one in the Exchange. Search there first. If there isn't one there, we can help you write the program.
|
|
|
|
|
|
#3 |
|
100 Club
Join Date: 2003-10
Location: Perth, West Australia
Posts: 114
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
There is a good lisp example at CADALYST>GET THE CODE> APRIL 2004 called OFFSET LINE by Will Deloach.
This might just be what you are looking for.... |
|
|
|
|
|
#4 |
|
Vice President / Director
Join Date: 2000-09
Location: Kenosha Wisconsin
Posts: 375
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
(defun C:OL ()
(while (not (setq lstSelection (entsel "\nSelect object to offset: "))) (princ "\nNull Selection please try again: ") ) (setq objSelection (vlax-ename->vla-object (car lstSelection)) lstPoint (vlax-curve-getClosestPointTo objSelection (cadr lstSelection)) sngParam (vlax-curve-getParamAtPoint objSelection lstPoint) sngSlope (vlax-curve-getFirstDeriv objSelection sngParam) sngAngle (+ (angle (list 0.0 0.0 0.0) sngSlope) (/ pi 2.0)) sngDistance (getdist "\nEnter offset distance: ") ) (vl-cmdf "offset" sngDistance lstPoint (polar lstPoint sngAngle 0.1) "" ) (vl-cmdf "offset" sngDistance lstPoint (polar lstPoint (+ pi sngAngle) 0.1) "" ) (if (not (tblsearch "ltype" "center")) (vla-load (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object) ) ) "center" "ACAD.LIN" ) ) (vla-put-linetype objSelection "center") (prin1) ) |
|
|
|
|
|
#5 |
|
Administrator
Join Date: 2001-08
Location: Seattle WA US
Posts: 4,393
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Well, if you are going to use ActiveX, why not use the Offset method?
Code:
(defun C:OL (/ pickEnt pickObj offDist)
(vl-load-com)
(setvar "ErrNo" 0)
(while (and (not (setq pickEnt (entsel))) (/= 52 (getvar "ErrNo"))))
(cond ((and pickEnt
(setq pickObj (vlax-EName->vla-Object (car pickEnt)))
(progn (initget 6)
(setq offDist (getdist "\nSpecify offset distance: "))))
(vla-Offset pickObj offDist)
(vla-Offset pickObj (- offDist))
(I:PutCL pickObj)))
(princ))
(defun I:PutCL (myObj / linetypes ltName)
(setq linetypes (vla-Get-Linetypes (vla-Get-Document myObj))
ltName "Center")
(cond ((vl-catch-all-error-p
(vl-catch-all-apply 'vla-Item (list linetypes ltName)))
(vla-Load linetypes
ltName
(cond ((= (getvar "Measurement") 0) "Acad.lin")
("AcadISO.lin")))))
(vla-Put-Linetype myObj ltName))
|
|
|
|
|
|
#6 |
|
Vice President / Director
Join Date: 2000-09
Location: Kenosha Wisconsin
Posts: 375
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I liked the errno condition and utilized the vla-offset method and converted to this.
Peter Jamtgaard Code:
(defun C:OL (/ lstSelection objSelection sngDistance)
(while (and (not (setq lstSelection (entsel "\nSelect object to offset: ")))
(/= (getvar "ErrNo") 52)
)
(princ "\nNull Selection please try again: ")
)
(if lstSelection
(progn
(setq objSelection (vlax-ename->vla-object (car lstSelection))
sngDistance (getdist "\nEnter offset distance: ")
)
(vla-offset objSelection sngDistance)
(vla-offset objSelection (- sngDistance))
(if (not (tblsearch "ltype" "center"))
(vla-load (vla-get-linetypes
(vla-get-activedocument
(vlax-get-acad-object)
)
)
"center"
"ACAD.LIN"
)
)
(vla-put-linetype objSelection "center")
)
)
(prin1)
)
|
|
|
|
|
|
#7 |
|
I could stop if I wanted to
Join Date: 2003-05
Posts: 335
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Here is my code that was published in the Cadalyst Mag.:
Code:
(defun c:ol (/ ent dist obj kwrd)
(vl-load-com)
(while (not ent)
(if (eq (setq ent (car (entsel "\nSelect line to offset: ")))
nil
)
(princ "\nThat was not a line. Please select again: ")
)
)
(initget (+ 1 2 4 64))
(setq dist (getdist "\nEnter offset distance: "))
(initget (+ 2 4) "Yes No")
(setq kwrd (getkword "\nDelete original object [Yes/No] <Yes>: "))
(if (/= kwrd "No")
(setq kwrd "Yes")
)
(setq obj (vlax-ename->vla-object ent))
(vla-offset obj dist)
(vla-offset obj (* dist -1))
(if (eq kwrd "Yes")
(vla-erase obj)
)
(princ)
)
Will DeLoach Last edited by RobertB : 2004-06-04 at 05:51 PM. |
|
|
|
|
|
#8 |
|
Wish List Manager
Join Date: 2000-11
Location: 147544
Posts: 3,397
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
It's like dueling code...I hear banjo's playing in the distance...Robert, your up next
|
|
|
|
|
|
#9 |
|
Vice President / Director
Join Date: 2000-09
Location: Kenosha Wisconsin
Posts: 375
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Brenda,
It isn't necessarily dueling code. It is evolving code. I am frequently shown new approaches and techniques when I present code. In this case Robert was correct in his commentary of my first post. I then updated my code to encorporate his suggestions. Humility is a necessary virtue to remain teachable. Keeping an open mind...Be quick to see where others are right... Accept criticism as help instead of feeling it is a put down. OK I will stop with the philosophy lecture.... I am read for another topic for discussion. Peter Jamtgaard |
|
|
|
|
|
#10 | |
|
Administrator
Join Date: 2001-08
Location: Seattle WA US
Posts: 4,393
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Quote:
Code:
(defun c:ol (/ ent dist obj kwrd)
(vl-load-com) ;<-good!
(while (not ent) ;<- this sort of loop is hard to get out of, see my code
(if (eq (setq ent (car (entsel "\nSelect line to offset: "))) ;<- (if (not (setq...)))
nil ;<- testing for nil is unneeded, use LISP's return values directly
)
(princ "\nThat was not a line. Please select again: ") ;<- what if I pick a circle?
)
)
(initget (+ 1 2 4 64)) ;<- use of the Z-blocker was nice
(setq dist (getdist "\nEnter offset distance: "))
(initget (+ 2 4) "Yes No") ;<- bits 2 and 4 server no purpose in (getkword)
(setq kwrd (getkword "\nDelete original object [Yes/No] <Yes>: ")) ;<- 2000-style options, good!
(if (/= kwrd "No") ;<- this statement is unneeded, see below
(setq kwrd "Yes")
)
(setq obj (vlax-ename->vla-object ent))
(vla-offset obj dist)
(vla-offset obj (* dist -1))
(if (eq kwrd "Yes") ;<- (/= kwrd "No")
(vla-erase obj)
)
(princ)
)
|
|
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Looking for a routine to draw building outlines | boesiii | AutoLISP | 10 | 2008-08-14 04:53 AM |
| Hatches, fills and lines | trombe | Revit Architecture - General | 6 | 2007-02-01 05:22 PM |
| TransformationMatrix | jwanstaett | VBA | 10 | 2005-10-05 04:47 PM |
| Inserting text offset from line | rortiz | AutoCAD Map 3D - General | 1 | 2005-05-26 11:58 PM |
| double line, dline command snaps not working | jvoight | AutoCAD LT - General | 2 | 2005-03-22 07:45 PM |