Saturday, November 21, 2009
Home   |   Search   |   About AUGI   |   My AUGI   |   Join Now

Go Back   AUGI Forums > AUGI Technical (English) > Programming > AutoLISP
 Welcome, Guest. 

Login

Join Now FAQ Members List Calendar Search Today's Posts Mark Forums Read

AutoLISP AutoLISP or Visual LISP, learn both here!

Reply
 
Thread Tools Display Modes
Old 2004-06-01, 04:26 PM   #1
BCrouse
All AUGI, all the time
 
BCrouse's Avatar
 
Join Date: 2003-04
Location: Bethlehem, PA
Posts: 967
BCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moon
Default Double Line Offset

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
BCrouse is offline   Reply With Quote
Old 2004-06-02, 12:51 AM   #2
RobertB
Administrator
 
RobertB's Avatar
 
Join Date: 2001-08
Location: Seattle WA US
Posts: 4,393
RobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the stars
Default RE: Dbl Line Offset

There might be one in the Exchange. Search there first. If there isn't one there, we can help you write the program.
RobertB is offline   Reply With Quote
Old 2004-06-02, 04:05 AM   #3
wpeacock
100 Club
 
wpeacock's Avatar
 
Join Date: 2003-10
Location: Perth, West Australia
Posts: 114
wpeacock has a bright futurewpeacock has a bright futurewpeacock has a bright futurewpeacock has a bright futurewpeacock has a bright futurewpeacock has a bright futurewpeacock has a bright future
Default RE: Dbl Line Offset

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....
wpeacock is offline   Reply With Quote
Old 2004-06-02, 02:44 PM   #4
peter
Vice President / Director
 
peter's Avatar
 
Join Date: 2000-09
Location: Kenosha Wisconsin
Posts: 375
peter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the stars
Default RE: Dbl Line Offset

(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)
)
peter is offline   Reply With Quote
Old 2004-06-02, 04:50 PM   #5
RobertB
Administrator
 
RobertB's Avatar
 
Join Date: 2001-08
Location: Seattle WA US
Posts: 4,393
RobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the stars
Default RE: Dbl Line Offset

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))
RobertB is offline   Reply With Quote
Old 2004-06-03, 02:22 PM   #6
peter
Vice President / Director
 
peter's Avatar
 
Join Date: 2000-09
Location: Kenosha Wisconsin
Posts: 375
peter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the stars
Default RE: Dbl Line Offset

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)
)
peter is offline   Reply With Quote
Old 2004-06-04, 02:24 PM   #7
whdjr
I could stop if I wanted to
 
Join Date: 2003-05
Posts: 335
whdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of light
Default RE: Dbl Line Offset

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)
)
Hope this helps,

Will DeLoach

Last edited by RobertB : 2004-06-04 at 05:51 PM.
whdjr is offline   Reply With Quote
Old 2004-06-04, 03:29 PM   #8
BrenBren
Wish List Manager
 
BrenBren's Avatar
 
Join Date: 2000-11
Location: 147544
Posts: 3,397
BrenBren is celestialBrenBren is celestialBrenBren is celestialBrenBren is celestialBrenBren is celestialBrenBren is celestialBrenBren is celestialBrenBren is celestialBrenBren is celestialBrenBren is celestialBrenBren is celestial
Default RE: Dbl Line Offset

It's like dueling code...I hear banjo's playing in the distance...Robert, your up next
__________________
Brenda Richardson
Wish List Manager

BrenBren is offline   Reply With Quote
Old 2004-06-04, 05:16 PM   #9
peter
Vice President / Director
 
peter's Avatar
 
Join Date: 2000-09
Location: Kenosha Wisconsin
Posts: 375
peter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the stars
Default RE: Dbl Line Offset

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
peter is offline   Reply With Quote
Old 2004-06-04, 06:03 PM   #10
RobertB
Administrator
 
RobertB's Avatar
 
Join Date: 2001-08
Location: Seattle WA US
Posts: 4,393
RobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the stars
Default RE: Dbl Line Offset

Quote:
Originally Posted by whdjr
Here is my code that was published in the Cadalyst Mag.:
Will, I've got some comments, I hope you don't mind.

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)
)
RobertB is offline   Reply With Quote
Reply


Go Back   AUGI Forums > AUGI Technical (English) > Programming > AutoLISP

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

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


All times are GMT +1. The time now is 04:29 PM.