Jump to content

Recommended Posts

Posted

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

 

Posted
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

 

Posted

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.

Posted

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

Posted

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

Posted

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

You guys are the best !!!!

Posted
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

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

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
Posted

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

Really appreciate your help. 

  • Like 1
Posted
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.

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