+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Forum Newbie
    Using
    AutoCAD 2016
    Join Date
    Jun 2015
    Posts
    2

    Default Autolisp function yields different results when ran on-screen vs. off-screen.

    Registered forum members do not see this ad.

    The source of the problem is a helper function drawportsegment:
    Code:
    (defun drawportsegment (loc portspacing / portw porth test)
    	(setq
    		portw 2.0
    		porth 1.0)
    
    	(command "rectangle"
    		(list (- (car loc) (/ portw 2.0)) (cadr loc) 0.0)
    		(list (+ (car loc) (/ portw 2.0)) (- (cadr loc) porth) 0.0))
    	(command "line"
    		(list (car loc) (- (cadr loc) porth) 0.0)
    		(list (car loc) (- (cadr loc) portspacing) 0.0)
    		"")
    )
    As it is relevant information, the test function I wrote to interface with drawportsegment is testdps:
    Code:
    (defun c:testdps (/ loc portspacing)
    	(setq 
    		loc (getpoint "\nwhere?")
    		portspacing 2.0)
    
    	(drawportsegment loc portspacing))
    Here is a direct comparison of this function running on-screen vs. off-screen:



    I do not understand why figure A is generated, as I would think from looking at the code that figure B would always be generated.

    All help is appreciated!

  2. #2
    Super Member Commandobill's Avatar
    Using
    AutoCAD 2014
    Join Date
    Oct 2008
    Location
    Raleigh, NC
    Posts
    538

    Default

    Code:
    (setvar 'osmode 0)
    ***Commandobill***
    Abusing AutoCad Since 1999
    "Caddatude... Do you has it?"
    Sorry for my poor English, I'm American...

  3. #3
    Super Member Commandobill's Avatar
    Using
    AutoCAD 2014
    Join Date
    Oct 2008
    Location
    Raleigh, NC
    Posts
    538

    Default

    To explain: When the object is on the screen your osnaps are active, this if you get the current osmode and set it to variable, then change the osmode to 0 while your program is running, then it will not snap to an object, then you turn it back to what it was.
    ***Commandobill***
    Abusing AutoCad Since 1999
    "Caddatude... Do you has it?"
    Sorry for my poor English, I'm American...

  4. #4
    Forum Newbie
    Using
    AutoCAD 2016
    Join Date
    Jun 2015
    Posts
    2

    Default

    It worked - thank you!

  5. #5
    Super Member Commandobill's Avatar
    Using
    AutoCAD 2014
    Join Date
    Oct 2008
    Location
    Raleigh, NC
    Posts
    538

    Default

    No problem
    ***Commandobill***
    Abusing AutoCad Since 1999
    "Caddatude... Do you has it?"
    Sorry for my poor English, I'm American...

  6. #6
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,577

    Default

    Registered forum members do not see this ad.

    A suggestion the changing of osmode is pretty common in lots of situations.

    Code:
    (setq oldsnap (getvar 'osmode))
    (setvar 'osmode 0)
    ....
    your code
    ...
    (setvar 'osmode oldsnap)
    A man who never made mistakes never made anything

Similar Threads

  1. The results obtained with the function grread
    By Costinbos77 in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 21st Feb 2013, 03:24 pm
  2. Replies: 5
    Last Post: 21st Oct 2010, 11:43 am
  3. Screen renderer shows black screen
    By cameroon95 in forum Cameras, Lighting & Rendering
    Replies: 2
    Last Post: 4th Nov 2009, 05:23 pm
  4. screen
    By apex in forum AutoCAD Drawing Management & Output
    Replies: 5
    Last Post: 26th Feb 2007, 11:21 pm
  5. On screen only?
    By nickahughes in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 22nd Feb 2007, 11:33 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts