Jump to content

Multi Offset with Different Distances


sidhu412

Recommended Posts

I think a bit of searching here would have produced an answer I know I posted a do lots offset routine that was based on + & - values to imply sides -4 -6 -8 etc this could have been changed to a defun (offs -4)(offs -9) using word etc it would be easy to produce the code the other alternative is the old fashioned script again Word or excel to create, but yes still need a list of numbers, will have to find code I think I did this one at home.

 

Here is the main code it will need a mod so that you run it like you want http://www.cadtutor.net/forum/showthread.php?85524-Multiple-offset-plines-done-easy-with-width-and-color&highlight=offset some one can rip it apart and make shorter I am sure back to work now. Will try later.

 

(load "multi")
(ah:multpl -4)
(ah:multpl -6)
(ah:multpl -

Edited by BIGAL
Link to comment
Share on other sites

  • Replies 32
  • Created
  • Last Reply

Top Posters In This Topic

  • sidhu412

    12

  • RobDraw

    7

  • BIGAL

    3

  • suryacad

    2

Top Posters In This Topic

Posted Images

I think that it is good start

(defun c:mofst (/)
 (setq doc (vla-get-ActiveDocument (setq *acad (vlax-get-Acad-Object)))
spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc)))
 (vl-load-com)
 (setq uFlag (vla-startUndoMark doc))
 (setq obj (entsel "\nSelectObject"))
 (setq s (getpoint "\nPick Offset side"))
 (setq o1 (getreal "\nWhat is distence for 1st offset?"))
 (setq o2 (getreal "\nWhat is distence for 2nd offset?"))
 (setq o3 (getreal "\nWhat is distence for 3rd offset?"))
 (vl-cmdf "_.offset" o1 obj s "")
 (vl-cmdf "_.offset" o2 obj s "")
 (vl-cmdf "_.offset" o3 obj s "")
 (setq uFlag (vla-EndUndoMark doc))
 )
(defun *error* (msg) (and uFlag (vla-EndUndoMark doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ))

 

 

Thnxxxxxxxxxxxxxx a lot, This is exactly what I wanted.

Really appreciated.

 

Thnx again man.

 

 

Regards,

 

 

Sidhu

Link to comment
Share on other sites

This is a variation of the asos200 were you may have more than 3 perhaps from some excel sheet etc reduced the code just for testing should put the error checking etc back in for rigidity. The offset code defun c:mosft can be done easy in word or excel probably the way to go is something like

 

(multpl 12 14 16 32 23)

(multpl 12 14 16 32 23 34 45 67 78) as many variables as required

 

;just need to keep the 6 top lines and add the rest of lines as required
(vl-load-com)
(defun c:mofst (o1 obj s/  )
  (vl-cmdf "_.offset" o1 obj s "")
)
(setq obj (entsel "\nSelectObject"))
(setq s (getpoint "\nPick Offset side"))
(c:mofst 12 obj s)
(c:mofst 14 obj s )
(c:mofst 16 obj s)
(c:mofst 22.5 obj s)
(c:mofst 34.75 obj s)

Link to comment
Share on other sites

This is a variation of the asos200 were you may have more than 3 perhaps from some excel sheet etc reduced the code just for testing should put the error checking etc back in for rigidity. The offset code defun c:mosft can be done easy in word or excel probably the way to go is something like

 

(multpl 12 14 16 32 23)

(multpl 12 14 16 32 23 34 45 67 78) as many variables as required

 

;just need to keep the 6 top lines and add the rest of lines as required
(vl-load-com)
(defun c:mofst (o1 obj s/  )
  (vl-cmdf "_.offset" o1 obj s "")
)
(setq obj (entsel "\nSelectObject"))
(setq s (getpoint "\nPick Offset side"))
(c:mofst 12 obj s)
(c:mofst 14 obj s )
(c:mofst 16 obj s)
(c:mofst 22.5 obj s)
(c:mofst 34.75 obj s)

 

Thanks for the Help.

 

Regards,

 

 

Sidhu

Link to comment
Share on other sites

BIGAL , take a look at the following and compare it with your suggestion :)

 

(if (and obj s)
 (mapcar '(lambda (i) (vl-cmdf "_.offset" i obj s "")) '(1. 2. 3.))
 )

Link to comment
Share on other sites

Thanks Tharwat I realised I needed to make the offsets a list the lambda function is a good way to step through a unknown list of offsets.

 

I also looked at the complexity of the code and broke it down to something simple just keep entering offsets till you run out. Sometimes we over complicate an answer.

 

(defun C:MULOFF ( / obj s off)
(vl-load-com)
(setq obj (entsel "\nSelectObject"))
(setq s (getpoint "\nPick Offset side"))
(while (/= (setq off (getreal "\nEnter offset or Enter to exit") nil)
(vl-cmdf "_.offset" off obj s "")
)
)

Link to comment
Share on other sites

Hi guys.

Can some body please explain how these codes that are pasted here are used?

i have used LISPS that can be downloaded. and then appload and use the call function as mentioned in lee mac's website.

got no idea how to use codes posted this way.

 

Thank you.

Link to comment
Share on other sites

Maybe sth like this :

;Multi Offset base		
(defun c:mob(/ o s l)
(if
	(setq 	o (entsel "\nSelect Object") 
			s	(getpoint "\nPick Offset side")
			l 	(read (strcat "(" (lisped "Type all distance, seperate by space ..") ")"))
	)		
	(mapcar '(lambda(i)(vl-cmdf "_.offset" i o "_non" s "")) l)
)
)
;Multi Offset Continous
(defun c:moc(/ o a s l)
(if
	(setq 	o (entsel "\nSelect Object")
			a 0
			s	(getpoint "\nPick Offset side")
			l 	(read (strcat "(" (lisped "Type all distance, seperate by space ..") ")"))
			l	(mapcar '(lambda(x)(setq a (+ x a))) l)
	)			
	(mapcar '(lambda(i)(vl-cmdf "_.offset" i o "_non" s "")) l)
)
)

Link to comment
Share on other sites

Maybe sth like this :

;Multi Offset base		
(defun c:mob(/ o s l)
(if
	(setq 	o (entsel "\nSelect Object") 
			s	(getpoint "\nPick Offset side")
			l 	(read (strcat "(" (lisped "Type all distance, seperate by space ..") ")"))
	)		
	(mapcar '(lambda(i)(vl-cmdf "_.offset" i o "_non" s "")) l)
)
)
;Multi Offset Continous
(defun c:moc(/ o a s l)
(if
	(setq 	o (entsel "\nSelect Object")
			a 0
			s	(getpoint "\nPick Offset side")
			l 	(read (strcat "(" (lisped "Type all distance, seperate by space ..") ")"))
			l	(mapcar '(lambda(x)(setq a (+ x a))) l)
	)			
	(mapcar '(lambda(i)(vl-cmdf "_.offset" i o "_non" s "")) l)
)
)

 

That's really very nice tool, thnx for Help

 

 

Regards,

 

 

Sidhu

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...