Jump to content
Hsanon

Osnap issues in code

Recommended Posts

Hsanon

Hi, Im facing a very strange issue in a part of my (very basic) code.....

 

(setq Vshelves (strcase (getstring "\nDo You want to have Vertical partitions?? [Yes/No] <Y> :")))
    (if (or (= Vshelves "Y") (= Vshelves ""))
        (while
        ;(setvar "osmode" 183) ; 
        (setq vspt (getpoint "\nPick Vertical Partition Start Point: "))
        (setq vdist (getdist vspt  "\nPick extent of the vertical partition ??   :"))
        ;(setvar "osmode" 0)
        (command "insert" "2dply" vspt plythk vdist   "" ) 
        );end while
        );end if

 

as soon as i keep the Osnap on, the program crashes .... and it works fine without the osnap in the code.... (but the exection is a pain)

i would need to have the osnaps on in the program !!!!

 

can someone tell me where i an going wrong ????

Thanks

 

Share this post


Link to post
Share on other sites
dlanorh
27 minutes ago, Hsanon said:

Hi, Im facing a very strange issue in a part of my (very basic) code.....

 

(setq Vshelves (strcase (getstring "\nDo You want to have Vertical partitions?? [Yes/No] <Y> :")))
    (if (or (= Vshelves "Y") (= Vshelves ""))
        (while
        ;(setvar "osmode" 183) ; 
        (setq vspt (getpoint "\nPick Vertical Partition Start Point: "))
        (setq vdist (getdist vspt  "\nPick extent of the vertical partition ??   :"))
        ;(setvar "osmode" 0)
        (command "insert" "2dply" vspt plythk vdist   "" ) 
        );end while
        );end if

 

as soon as i keep the Osnap on, the program crashes .... and it works fine without the osnap in the code.... (but the exection is a pain)

i would need to have the osnaps on in the program !!!!

 

can someone tell me where i an going wrong ????

Thanks

 

 

The answer is what is controlling the while loop. As it is, selecting a point is the controlling factor. If you uncomment (setvar "osmode" 183) this then controls the while loop.

 

Try this, not tested

(setq Vshelves (strcase (getstring "\nDo You want to have Vertical partitions?? [Yes/No] <Y> :")))
(setvar "osmode" 183)  
(if (or (= Vshelves "Y") (= Vshelves ""))
  (while (setq vspt (getpoint "\nPick Vertical Partition Start Point: "))
   	(setq vdist (getdist vspt  "\nPick extent of the vertical partition ??   :"))
   	(setvar "osmode" 0)
   	(command "insert" "2dply" vspt plythk vdist   "" )
  	(setvar "osmode" 183)  
  );end while
);end if

 

Share this post


Link to post
Share on other sites
pkenewell

Another way would be to override the osnaps within the command - no need to change OSMODE.

i.e.  (command "insert" "2dpoly" "non" vspt plythk vdist ""). NON tells the command to ignore osnaps for the next point specified.

Share this post


Link to post
Share on other sites
BIGAL

Add (setq oldnsap (getvar 'osmode)) so save current osmode, then add at end (setvar 'osmode oldsnap)

Share this post


Link to post
Share on other sites
Hsanon

Hey. Thanks..... Really appreciate it.... Lemmie check it out. 

Share this post


Link to post
Share on other sites
Hsanon

Thanks so much ..... That issue has been resolved !!!

You guys are the best !!!!

Share this post


Link to post
Share on other sites
Hsanon
20 hours ago, pkenewell said:

Another way would be to override the osnaps within the command - no need to change OSMODE.

i.e.  (command "insert" "2dpoly" "non" vspt plythk vdist ""). NON tells the command to ignore osnaps for the next point specified.

This works for the insert command, but not for copy or move as i see it.  

But its a brilliant option for the insert command !!! thanks

Share this post


Link to post
Share on other sites
pkenewell
Posted (edited)
6 hours ago, Hsanon said:

This works for the insert command, but not for copy or move as i see it.  

But its a brilliant option for the insert command !!! thanks

@Hsanon

The "non" (or "none") modifier should work for ANY Autocad command that requests a point. I use this all the time, both in autoLISP and at the command line. The modifier has to be requested before EACH point specified.

 

Examples:

(command "._line" "_non" p1 "_non" p2 "") ;;note: the underscore ("_") prefix in the command options - although not necessary - allow for international usage; they translate to the local language.

(command "._arc" "_non" p1 "_non" p2 "_non" p3)

Edited by pkenewell

Share this post


Link to post
Share on other sites
Hsanon
8 hours ago, pkenewell said:

@Hsanon

The "non" (or "none") modifier should work for ANY Autocad command that requests a point. I use this all the time, both in autoLISP and at the command line. The modifier has to be requested before EACH point specified.

 

Examples:

(command "._line" "_non" p1 "_non" p2 "") ;;note: the underscore ("_") prefix in the command options - although not necessary - allow for international usage; they translate to the local language.

(command "._arc" "_non" p1 "_non" p2 "_non" p3)

The copy command and move command didn't seem to work.... with "non"

Maybe I should try again.... thanks 

Share this post


Link to post
Share on other sites
pkenewell
Posted (edited)
On 6/27/2020 at 1:17 AM, Hsanon said:

The copy command and move command didn't seem to work.... with "non"

Maybe I should try again.... thanks 

Works for me. Try this in a drawing with a few items to copy. I suspect you need to get your COPY command sequence correct.

(defun C:foo ()
   (princ "\n Selected Objects: ")
   (if (setq ss (ssget))
      (command "._copy" ss "" "_non" "0,0,0" "_non" "1,1,0")
   )
   (princ)
)

 

Edited by pkenewell

Share this post


Link to post
Share on other sites
Hsanon

Hey thanks... Lemmie try it in my existing code. 

Really appreciate your help. 

  • Like 1

Share this post


Link to post
Share on other sites
pkenewell
Just now, Hsanon said:

Hey thanks... Lemmie try it in my existing code. 

Really appreciate your help. 

No problem! Let me know how it works out for you. If you're still having some issues - post your code.

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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