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

Help with new macro

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
cadman33619
740 Views, 10 Replies

Help with new macro

hi all,

 

i've been trying to create a macro that will stramline a repetetive command but I'm lost and confused. 

 

i have single lines ( a whole lot of them) along roadways that i need to convert to double lines with a certain width (.8). I have (what i think is) a lisp routine (a .fas file) that someone provided that changes the line to a double line....but what i need is to tell it to use the same width each time. so that it will go faster. and if it had the MULTIPLE option, that would be even better.

 

is all of this wishful thinking on my part?

10 REPLIES 10
Message 2 of 11
_Tharwat
in reply to: cadman33619

This ?

 

(defun c:Test (/ ss i o)
  (if (setq ss (ssget "_:L" '((0 . "LINE"))))
    (repeat (setq i (sslength ss))
      (setq o (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
      (foreach x (list 0.8 -0.8)
        (vla-offset o x)
      )
    )
  )
  (princ)
)(vl-load-com)

 

Message 3 of 11
Kent1Cooper
in reply to: cadman33619


@cadman33619 wrote:

... 

i have single lines ( a whole lot of them) along roadways that i need to convert to double lines with a certain width (.8). ....


If you want the double line centered around the original, you can use the attached OffsetBothSides.lsp with its OBS command.  In your example case, give it .4 [half the desired spacing] for the offset distance.  You can select as many things [of any Offsettable type) as you want to double-offset that way, in one running of the command, and it remembers your distance and offers it as the default when you use the command again in the same drawing session.

 

It currently leaves the original middle object in place, but if you want that removed, that would be an easy adjustment.

Kent Cooper, AIA
Message 4 of 11
cadman33619
in reply to: Kent1Cooper

Kent...

 

i would need the original line removed. Can you do that for me?

 

I have no experience at all dealing with writing/creating lisp commands. I'm still trying to figure out how to apply/use the code provided by Tharwat....i suppose I should have just asked him.

Message 5 of 11
Kent1Cooper
in reply to: cadman33619


@cadman33619 wrote:

.... 

i would need the original line removed. Can you do that for me?

....


A quickie alteration of the other one, into an OffsetBothSidesErase.lsp file with its OBSE command....

Kent Cooper, AIA
Message 6 of 11
cadman33619
in reply to: Kent1Cooper

works perfectly. thanks so much.

 

 

Message 7 of 11
cadman33619
in reply to: cadman33619

and thank you to Tharwat for the info.... You've inspired me to learn more about how that works. 

Message 8 of 11
_Tharwat
in reply to: cadman33619


@cadman33619 wrote:

and thank you to Tharwat for the info.... You've inspired me to learn more about how that works. 


Happy to hear that , and do not hesitate to ask if you have any question .

 

Regards.

 

Tharwat

Message 9 of 11
cadman33619
in reply to: Kent1Cooper

out of curiosity, Kent... would it be possible to add the WINDOW option to that? ie... if i have lots of them..i can isolate that layer then start the command then window all of them... and get them all done at once?

 

not trying to be greedy here... what you provided is already a HUGE time-saver. just thought that would be nice. 

Message 10 of 11
Kent1Cooper
in reply to: cadman33619


@cadman33619 wrote:

.... would it be possible to add the WINDOW option to that? ie... if i have lots of them..i can isolate that layer then start the command then window all of them... and get them all done at once?

.... 


Not difficult [not just the Window option, but any selection method(s)], but not today....  Watch this space.

Kent Cooper, AIA
Message 11 of 11
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

@cadman33619 wrote:

.... would it be possible to add the WINDOW option to that? ..... 


Not difficult [not just the Window option, but any selection method(s)], but not today....  Watch this space.


Give this a shot.

 

In testing, I find that for some reason it doesn't like to work with Rays.  [It seems to work for everything else.]  It also seems to be true of the original OBS command that doesn't delete the selected thing in the middle [I must not have tested it thoroughly enough back then...].  Rays are perhaps a comparatively rare thing, and that may not be an issue for you, but if others have any idea why that should be, I'd be interested in theories.  It's on my old version here, and I'll try it on 2015 when I get to it, in case it's version-specific, so I'd also be interested in whether it works for some versions.  Or is there just some kind of incompatibility with (vla-offset) and the Ray object type?

Kent Cooper, AIA

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

Post to forums  

Autodesk Design & Make Report

”Boost