How create DXf group with vaiable in it? (Trying to write scale of my modelspace viewport to Diction

Discussion in 'AutoCAD' started by Steve Adams, Feb 12, 2005.

  1. Steve Adams

    Steve Adams Guest

    Hello Everybody,

    I plot in paperspace on 1=1 scale. After plotting, I would like to restore
    my modelspace view and have my scale (ltscale and dimscale) restored at the
    same time.

    In doing this, I want to write the "scale" to a dictionary. To write to the
    dictionary, I am using makexrecord.lsp & listxrecord.lsp which someone else
    around here kindly provided a while back.

    My problem comes in trying to creating a DXF group with a variable in it.

    ERROR: bad DXF group: (CONS 1 SC) , where SC is my string variable

    the program shoud ask me what the scale is, then write it to dictionary:
    ----------------------------------------------------------------------------
    (defun MAKEXRECORD3 ()
    (SETQ sc(getstring "\nScale of view?: "))
    (setq xrec '((0 . "XRECORD")(100 . "AcDbXrecord")
    ;;;;;(1 . "50") ; it works in this form
    (cons 1 sc) ; does NOT work in this form <<<<<<<<<<<<<<<<<<<<<<<<<<
    (10 1.0 2.0 0.0 )(40 . 3.14159) (50 . 3.14159)
    (62 . 1)(70 . 180))
    )
    (setq xname (entmakex xrec))
    (dictadd (namedobjdict) "XRECLIST" XNAME)
    (princ)
    )
    (makexrecord3)
    ----------------------------------------------------------

    ERROR: bad DXF group: (CONS 1 SC)

    Question: How can I put the value of that variable in the DXF group?

    Thanks,
    Steve (Acad2005 Vanilla SP1, W2K SP4)
     
    Steve Adams, Feb 12, 2005
    #1
  2. Try --

    Code:
    
    (setq xrec
    (append
    '(   (0 . "XRECORD")
    (100 . "AcDbXrecord")
    )
    (list (cons 1 sc))
    '(   (10 1.0 2.0 0.0)
    (40 . 3.14159)
    (50 . 3.14159)
    (62 . 1)
    (70 . 180)
    )
    )
    )
    
    or
    
    (setq xrec
    (list
    '(0 . "XRECORD")
    '(100 . "AcDbXrecord")
    (cons 1 sc)
    '(10 1.0 2.0 0.0)
    '(40 . 3.14159)
    '(50 . 3.14159)
    '(62 . 1)
    '(70 . 180)
    )
    )
    
    
    Hello Everybody,

    I plot in paperspace on 1=1 scale. After plotting, I would like to restore
    my modelspace view and have my scale (ltscale and dimscale) restored at the
    same time.

    In doing this, I want to write the "scale" to a dictionary. To write to the
    dictionary, I am using makexrecord.lsp & listxrecord.lsp which someone else
    around here kindly provided a while back.

    My problem comes in trying to creating a DXF group with a variable in it.

    ERROR: bad DXF group: (CONS 1 SC) , where SC is my string variable

    the program shoud ask me what the scale is, then write it to dictionary:
    ----------------------------------------------------------------------------
    (defun MAKEXRECORD3 ()
    (SETQ sc(getstring "\nScale of view?: "))
    (setq xrec '((0 . "XRECORD")(100 . "AcDbXrecord")
    ;;;;;(1 . "50") ; it works in this form
    (cons 1 sc) ; does NOT work in this form <<<<<<<<<<<<<<<<<<<<<<<<<<
    (10 1.0 2.0 0.0 )(40 . 3.14159) (50 . 3.14159)
    (62 . 1)(70 . 180))
    )
    (setq xname (entmakex xrec))
    (dictadd (namedobjdict) "XRECLIST" XNAME)
    (princ)
    )
    (makexrecord3)
    ----------------------------------------------------------

    ERROR: bad DXF group: (CONS 1 SC)

    Question: How can I put the value of that variable in the DXF group?

    Thanks,
    Steve (Acad2005 Vanilla SP1, W2K SP4)
     
    Michael Puckett, Feb 12, 2005
    #2
  3. Steve Adams

    Steve Adams Guest

    Michael,

    Thank you. That works great.

    I appreciate it.

    Steve
     
    Steve Adams, Feb 12, 2005
    #3
  4. My pleasure; thanks Steve.

    Michael,

    Thank you. That works great.

    I appreciate it.

    Steve
     
    Michael Puckett, Feb 13, 2005
    #4
  5. Another possibility, if I understand what you're trying to do -- use two of
    the USERI1 through USERI5 system variables for paperspace and modelspace
    scale factors.
    (setvar "USERI4" 1)
    (setvar "USERI5" 50); <<<[vary that by scale of drawing, of course]

    When you go into paper space, have something do
    (setvar "DIMSCALE" (getvar "USERI4"))
    (setvar "LTSCALE" (getvar "USERI4"))

    When you go into model space, have something do
    (setvar "DIMSCALE" (getvar "USERI5"))
    (setvar "LTSCALE" (getvar "USERI5"))
     
    Kent Cooper, AIA, Feb 14, 2005
    #5
  6. Steve Adams

    Steve Adams Guest

    Thanks Kent,

    That would be simpler than writing to dictionary. I do have "USERI2" &
    "USERI3" available. The rest are being used by my old DCA routines.

    Is this true: the 15 "user" variables, block attributes, xdata and
    dictionaries are the only way to store variable values permanently in the
    dwg?

    --
    Thanks,
    Steve

     
    Steve Adams, Feb 14, 2005
    #6
  7. I don't know about "only", but I do know that the USERS# ones (the string
    variables) are NOT saved in the drawing file. For some inexplicable reason,
    they're only kept during the drawing session, so you can't recall them after
    you've closed and reopened a drawing. I think I suggested their use as a
    possible solution to some newsgroup posted question, not knowing this about
    them at the time. So it was a disappointing surprise to find that they're
    not saved.

    For purposes of your question here (scale factors), if you ran out of USERI#
    variables, you could use USERR# variables instead, but of course that
    wouldn't work for certain types of variables, like system variables that
    must be integers.

    There are other "imaginative" ways to store variable things in a drawing, if
    you really needed something off the wall. You could make a Layer and store
    a text string (that fits in the length limits, of course) in its Layer name;
    likewise with a Block, or I guess anything that Rename can change the name
    of. That could include numerical variables, which can be converted back
    from text to numbers with Lisp. In some of those cases, you might have to
    draw something on them or in them or with them, presumably in some
    non-plotting way, so they can't be Purged. You could put some
    special-purpose piece of Text somewhere, with the variable in its text
    content. But those out-of-the-ordinary methods would all be more
    complicated to extract the variable from than the ones you mention.

    You could also put something like that (within limits) into standard System
    Variables that you never use. For us, that would include dimension
    tolerances and alternates, and probably some other dimensioning variables.
    They'd be easy to get the variable information back out of, but you'd have
    to be careful, and be pretty darned sure you wouldn't need to use the
    variables for their original purposes, and remember which you used for what
    (or always get them by way of defined routines that know where to look).
     
    Kent Cooper, AIA, Feb 14, 2005
    #7
  8. Steve Adams

    Steve Adams Guest

    Thanks, Kent. Those are very interesting (and easy) methods to store values.

    --
    Thanks,
    Steve


     
    Steve Adams, Feb 14, 2005
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.