Jump to content

Multiple Offset Command Error


DD21988

Recommended Posts

I have been trying to write a multiple offset command but when I run my command, after I set the offset distance and select an object, I get the error message: no function definition: CAD. Any idea how I can fix this command? I would appreciate any help you guys could provide.

 

 

;* C:MOFFSET is a multiple offset command. It requires the user to show the

;* offset direction, select one object, tell how many times to offset it

;* and give a direction for the offset. It requires the User GET Functions.

;*

(defun C:MOFFSET( / ent spt dist)

(setq #mdist (udist 1 "" "Offset distance " #mdist nil)) ;the distance to offset

(while (not (setq ent (entsel "\nSelect object to offset: ")))) ;get the object

(setq spt (upoint 1 "" "Select side" nil (cad ent)) ;get which side

#mnum (uint 5 "" "How many times " #mnum) ;# times

);setq

(setq dist #mdist) ;set a variable to the distance interval

(repeat #mnum ;program loop

(command "offset" dist ent spt "") ;run the offset command

(setq dist (+ dist #mdist)) ;increment the offset distance

);repeat

(princ) ;clean ending

);defun

(princ) ;clean loading

;*

 

 

The User GET functions I am using in this LISP are below and to my knowledge work fine, but I think it is easier to troubleshoot when you can test at the end.

 

 

;* UDIST: User interface distance function

;* BIT (0 for none) and KWD key word ("" for none) are same as for INITGET.

;* MSG is the prompt string, to which a default real is added as (nil

;* is for none), and a : is added. BPT is base point (nil for none).

(defun udist (bit kwd msg def bpt / inp )

(if def ;test for a default

(setq msg (strcat "\n" msg ": ") ;string'em with default

bit (* 2 (fix (/ bit 2))) ;a default and no null bit code conflict so

);setq ;this reduces bit by 1 if odd, to allow null

(if (= " " (substr msg (strlen msg) 1)) ;no def, if last char is space

(setq msg (strcat "\n" (substr msg 1 (1- (strlen msg))) ": ")) ;then strip space

(setq msg (strcat "\n" msg ": ")) ;else msg OK

) );if,if

(initget bit kwd)

(setq inp

(if bpt ;check for a base point

(getdist msg bpt) ;and use it in the GET commands

(getdist msg)

) );setq&if

(if inp inp def) ;compare the results, return appropriate value

);defun

;*

 

 

;* UPOINT User interface point function

;* BIT (1 for no null, 0 for none) and KWD key word ("" for none) are same as

;* for INITGET. MSG is the prompt string, to which a default point variable is

;* added as (nil is for none), and a : is added. BPT is base point (nil for none).

(defun upoint (bit kwd msg def bpt / inp)

(if def ;check for a default

(setq pts (strcat

(rtos (car def)) "," (rtos (cadr def)) ;formats X,Y 2D pt as string

(if ;formats 3D ,Z if supplied and FLATLAND off

(and (caddr def) (= 0 (getvar "FLATLAND")))

(strcat "," (rtos (caddr def)))

""

) );if&strcat

msg (strcat "\n" msg ": ") ;string them with default

bit (* 2 (fix (/ bit 2))) ;a default and no null bit code conflict so

) ;this reduces bit by 1 if odd, to allow null

(if (= " " (substr msg (strlen msg) 1)) ;no def, if last char is space

(setq msg (strcat "\n" (substr msg 1 (1- (strlen msg))) ": ")) ;then strip space

(setq msg (strcat "\n" msg ": ")) ;else msg OK

) );if,if

(initget bit kwd)

(setq inp

(if bpt ;check for base point

(getpoint msg bpt) ;and use it

(getpoint msg) ;but not if nil

) );setq&if

(if inp inp def) ;evaluate results and return proper value

);defun

;*

 

 

;* UINT: User interface integer function

;* BIT (0 for none) and KWD key word ("" for none) are same as for INITGET.

;* MSG is the prompt string, to which a default integer is added as (nil

;* for none), and a : is added.

;*

(defun uint (bit kwd msg def / inp)

(if def ;test for a default

(setq msg (strcat "\n" msg ": ") ;string'em with default

bit (* 2 (fix (/ bit 2))) ;a default and no null bit code conflict so

) ;this reduces bit by 1 if odd, to allow null

(if (= " " (substr msg (strlen msg) 1)) ;no def, if last char is space

(setq msg (strcat "\n" (substr msg 1 (1- (strlen msg))) ": ")) ;then strip space

(setq msg (strcat "\n" msg ": ")) ;else msg OK

) );if,if

(initget bit kwd)

(setq inp (getint msg)) ;use the GETINT function

(if inp inp def) ;compare the results, return appropriate value

);defun

;*

Link to comment
Share on other sites

You are meant to put your code in code tags(?), I think that is what they are called.

If you look at another post showing lisp you will see what I mean, no doubt a moderator will advise.

 

You might want to look at this gem by Lee Mac,

 

http://www.lee-mac.com/dynamicoffset.html

 

Thanks Lee! :beer:

 

as no doubt you will learn plenty from his code, and might decide you don't need to write a new one. :)

Link to comment
Share on other sites

Thanks for the link to the Lee Mac site. I will play with his as it seems to accomplish my goals. I couldn't figure out how to use the code tags. Is there a how to somewhere for that?

Link to comment
Share on other sites

I couldn't figure out how to use the code tags. Is there a how to somewhere for that?

 

Please refer to the Code Posting Guidlines.

 

In essence, you should edit your posts and surround your code with 'code' tags:

 

[highlight][noparse]

[/noparse][/highlight]Your code here[highlight][noparse]

[/noparse][/highlight]

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...