dimblk, dimblk1, dimblk2

Discussion in 'AutoCAD' started by Robert Good, Jun 28, 2004.

  1. Robert Good

    Robert Good Guest

    In autocad 2004/2005 you cannot access the dimblk variables thru the namedobjtable. Instead Autodesk suggests accessing these variables thru objectid's

    I am at a loss on how to access the objectid's without actually having to draw the dimension. I have tried to access the objectid's thru the dimstyle, but have not had any luck.

    Please Help.

    Robert Good.
     
    Robert Good, Jun 28, 2004
    #1
  2. Robert Good

    Rudy Tovar Guest

    As I mentioned before, you have to use activex.

    Make the style current, then use vla functions to retrieve the variables.

    Future dxf codes will be eliminated, and only be accessible through activex.
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi


    namedobjtable. Instead Autodesk suggests accessing these variables thru
    objectid's
    draw the dimension. I have tried to access the objectid's thru the dimstyle,
    but have not had any luck.
     
    Rudy Tovar, Jun 29, 2004
    #2
  3. Robert Good

    Robert Good Guest

    Rudy,
    My goal here is to get the variables of a child dimension style, which may
    be different than the current dimstyle setting.

    Lets say you have arch tics for your dimblk settings on linear dimensions,
    but want arrow heads on angular dimensions.

    This is a very pertinant question, considering there will be no access to
    these dxf values in the future.

    Robert Good.
     
    Robert Good, Jun 29, 2004
    #3
  4. Robert Good

    Rudy Tovar Guest

    Then vla make the object and feed the variables on how it's to appear.

    In other words, write a utility to place said dimension style, while you
    define how that object is suppose to appear.

    Or create a reactor to monitor which command is issued, and have it set and
    make the style current with the proper settings.
     
    Rudy Tovar, Jun 30, 2004
    #4
  5. Robert Good

    RobertGood Guest

    To add to my previous question. I am writing a utility that can export dimension settings to an external text file. (The express tools dim export utility is what I am trying to achieve.)
    The only think I am not able to access is the dmblk variables of children dimstyles.

    If the dim export utility can accomplish this task, it must be possible.

    (should I be asking the objectARX Group instead??)

    Robert Good.
     
    RobertGood, Jul 1, 2004
    #5
  6. Robert Good

    Mark Propst Guest

    dimension settings to an external text file. (The express tools dim export
    utility is what I am trying to achieve.)
    If you know arx, I'm sure there'd be a way to do that, and if you have an
    arx question, I'm sure they'd be happy to try and answer it.
    Since this is in the lisp group, I'd just say, I don't know of a way through
    lisp or vb via activex to get at properties of a dimension style without
    querying an instance of an object of that type. ie yes, you have to 'draw' a
    dimension which would have the style in which you are interested, then
    'read' the object to see what his 'properties' are.
    So if you wanted to know the name of the dimension block used for a radial
    dimension of style "Dim1"
    you could create a dimradial object, set it's stylename property to "Dim1",
    then read it's properties, like ArrowheadBlock, ArrowheadType,
    ArrowheadSize.
    eg: to list all blocknames for all radial children styles in oDoc

    ;excerpt from cond statement
    ((= childcode "$4");isolate radial child styles
    ;assuming functions that return the model space object and the active
    document
    ;assuming valid vals for p1 p2 obviously
    (setq testdim(vla-adddimradial(GetModelSpace(GetActiveDoc))p1 p2 10))
    ;assuming a subfunc that returns all dimstyle names
    (foreach ds(GetDimstyles oDoc)
    (vlax-put-property testdim 'stylename ds) ;set the style
    ;read properties and print out
    (princ(strcat"\nArrowheadBlock for style: " ds " "(vlax-get-property
    testdim 'ArrowheadBlock)))
    (princ(strcat"\nArrowheadSize for style: " ds "
    "(rtos(vlax-get-property testdim 'ArrowheadSize))))
    (princ(strcat"\nArrowheadType for style: " ds "
    "(itoa(vlax-get-property testdim 'ArrowheadType))))
    );for
    )
    ;;then delete test dim and release variable if need be
    course if it's the default arrowhead block, the name will be "" even if it's
    really "ClosedFilled"
    and you'd create one with "." i think...?

    maybe someone knows an easier way? i don't.
    hth
    Mark
     
    Mark Propst, Jul 2, 2004
    #6
  7. Robert Good

    Steve Doman Guest

    Robert,

    Have you tried iterating through each Dimstyle and setting any
    childstyles active via the Dimstyle command, then reading the dimvars?

    Not sure if the snip below helps:

    (setq dimstyle (list "standard$0" "standard$7")) ;etc.
    (setq varlist (list "dimblk" "dimblk1" "dimblk2"))

    (foreach child dimstyle
    (command "dimstyle" "restore" child)
    (foreach var varlist
    (do_something_with var)
    )
    )

    Steve Doman
     
    Steve Doman, Jul 2, 2004
    #7
  8. Robert Good

    Robert Good Guest

    thanks for the response mark.

    For some unknown reason, in my minds eye. Creating a dimension to get the variables instead of pulling it from the drawing database seems backwards and cumbersome.
    But, as we both know, to get the job done you have to do anything you can.
    Ill ask around on the objectarx threads. If I dont get what I want there, I will have to break down and actually draw the dims and get the variables.

    Thanks Again,
    Rob.
     
    Robert Good, Jul 3, 2004
    #8
  9. Robert Good

    Robert Good Guest

    Steve,

    To my knowledge, It is not possible to set a child dimension style current. (please correct me if I'm wrong)

    Thanks for the reply.

    Rob.
     
    Robert Good, Jul 3, 2004
    #9
  10. Robert Good

    Steve Doman Guest

    Robert,

    I'm no expert at dimstyles but did you try setting a child dimstyle
    active to see what happens? I hadn't tried it for a while myself and
    your reply made me curious to see if it was no longer possible.

    Prior to AutoCAD2k I now recall, the ability to set a child dimstyle
    active was very straight forward -- (command "-dimstyle" "restore"
    "Test$7" ...)

    Anyhow while experimenting with the modern version of the Dimstyle
    command (I'm testing on A2k5), it *appears* that you can set a parent
    dimstyle active, but not a child style.

    However if you run the Dimstyle command and tell it to restore a child
    style and then examine the dimvars afterwards, you'll see that the child
    dimvars are accessible.

    So perhaps using the Dimstyle command to set a child style active is a
    kludge, seeing how AutoCAD seems to be trying to prevent the user to
    doing that. It does appear to work, but maybe there are some pitfalls
    with this method that I'm not aware of.

    Here's a command log using the Dimstyle command where I "restore" a
    child dimstyle. In this example, the parent dimstyle has DimClrd var
    set to zero, while the child style is set to 8:

    Command: (getvar "dimstyle")
    "TEST"

    Command: (getvar "dimclrd")
    0

    Command: -dimstyle

    Current dimension style: TEST
    Enter a dimension style option
    [Save/Restore/STatus/Variables/Apply/?] <Restore>: restore

    Enter a dimension style name, [?] or <select dimension>: test$7

    Current dimension style: TEST
    Current dimension overrides:
    DIMCLRD 8

    Command: (getvar "dimclrd")
    8

    * Also as a footnote, ActiveX seems to work too:

    (vla-put-activedimstyle
    *doc*
    (vla-item dimstyles "TEST$7")
    )

    HTH

    Regards,
    Steve Doman
     
    Steve Doman, Jul 5, 2004
    #10
  11. Robert Good

    Steve Doman Guest

    Robert et al,

    Here's what I came up with so far. It's a work in progress and not
    tested much.

    Let me know if it works for you please.

    Regards,
    Steve Doman

    Code:
    (defun GetDimvars (parent / doc saved collection pat name namelist var
    varlist val rslt lst pat
    )
    ;;
    ;; Steve Doman 07-05-04 beta
    ;;
    ;; Given a parent dimstyle name, returns a list of dimvars
    ;; for each child style in the dimension style family
    ;; (getdimvars "standard") -> (("STANDARD" ("dimadec" . 0) ... ))
    ;;
    (setq parent (strcase parent))
    (setq doc (vla-get-activedocument (vlax-get-acad-object)))
    (setq saved (vla-get-activedimstyle doc))
    (setq collection (vla-get-dimstyles doc))
    (setq pat (strcat parent "," parent "$[023467]")) ;_ for wcmatch
    ;; The following list of dimvars may need to be adjusted cause
    ;; I haven't checked them over yet.
    (setq varlist (list "dimadec" "dimalt" "dimaltd" "dimaltf"
    "dimaltrnd" "dimalttd" "dimalttz" "dimaltu"
    "dimaltz" "dimapost" "dimaso" "dimassoc"
    "dimasz" "dimatfit" "dimaunit" "dimazin"
    "dimblk" "dimblk1" "dimblk2" "dimcen" "dimclrd"
    "dimclre" "dimclrt" "dimdec" "dimdle" "dimdli"
    "dimdsep" "dimexe" "dimexo" "dimfit" "dimfrac"
    "dimgap" "dimjust" "dimldrblk" "dimlfac"
    "dimlim" "dimlunit" "dimlwd" "dimlwe" "dimpost"
    "dimrnd" "dimsah" "dimscale" "dimsd1" "dimsd2"
    "dimse1" "dimse2" "dimsho" "dimsoxd" "dimtad"
    "dimtdec" "dimtfac" "dimtih" "dimtix" "dimtm"
    "dimtmove" "dimtofl" "dimtoh" "dimtol" "dimtolj"
    "dimtp" "dimtsz" "dimtvp" "dimtxsty" "dimtxt"
    "dimtzin" "dimunit" "dimupt" "dimzin"
    )
    )
    ;; Make a list of each child style in dimstyle family
    (vlax-for itm collection
    (setq name (strcase (vla-get-name itm)))
    (if (wcmatch name pat)
    (setq namelist (cons name namelist))
    )
    )
    ;; Set each child style active and collect dimvars
    (foreach name (reverse namelist)
    (vla-put-activedimstyle doc (vla-item collection name))
    (foreach var varlist
    (setq val (getvar var))
    ;;(cond ((and (= (type val) 'STR) (= val "")) (setq val ".")))
    (setq lst (cons (cons var val) lst))
    )
    (setq rslt (cons (cons name (reverse lst)) rslt))
    (setq lst nil)
    )
    ;; restore active dimstyle
    (vla-put-activedimstyle doc saved)
    (reverse rslt)
    )
    
     
    Steve Doman, Jul 6, 2004
    #11
  12. Robert Good

    RobertGood Guest

    Steve,
    I looked at your routine and put it thru a test on a dimstyle with children styles. It did give the variables for each child style. Awesome.
    I was under the preconceived notion that we were not able to set the child dimstyles current and did not even try to test that statement.
    Thanks Steve,
    I will continue to study your clip and post back any further findings I have.

    Thanks again,

    Robert Good.
     
    RobertGood, Jul 6, 2004
    #12
  13. Robert Good

    Steve Doman Guest

    Hi Robert,

    Glad it worked for you. I'm testing on A2k5 if that matters. There may
    be some dimvars compared to earlier versions of AutoCAD.

    One side effect I just noticed when after running the GetDimvar function
    is when it restores the dimstyle that was active at runtime, any
    pre-existing dim var overrides are wiped out :( In other words, if you
    had say dimscale set to 96 as an override, then after the GetDimvar
    function runs, the dimscale is reset to whatever is defined as dimscale
    in the dimstyle (probably 0 or 1).

    Not sure what to do about that if anything. Any comments or ideas?

    Thanks,
    Steve Doman
     
    Steve Doman, Jul 6, 2004
    #13
  14. Robert Good

    rgood Guest

    Steve,
    I am also testing your routine on 2005. I took out two dimvar's due to them being obsolete in 2004 and 2005.

    DIMUNIT (obsolete, now use DIMLUNIT AND DIMFRAC)
    DIMFIT (obsolete, now use DIMATFIT and DIMTMOVE)

    I am currently having problems with my current dimension creation routine crashing autocad speratically. I'm hoping taking those variables out of the equation might help.

    I am using your clip to export all the settings to a text file that can be imported on the fly to create a dimstyle when needed.
    I will write back when I can post something worthy.

    Robert Good
     
    rgood, Jul 7, 2004
    #14
  15. Robert Good

    Steve Doman Guest

    Robert,

    Thanks for the heads up on the dimvars. Interestingly I created the
    dimvar list by copy pasting the results from using the Set command in
    A2k5. Apparently the obsolete dimvars are still present for backward
    compatibility.

    I look forward to seeing what you come up with for exporting and
    importing since AutoCAD seems to no longer contain a DimIm or DimEx in
    the Express Tools.

    If you need any more help, I'll be glad to assist if I can.

    Regards,
    Steve Doman
     
    Steve Doman, Jul 8, 2004
    #15
  16. Robert Good

    rgood Guest

    Steve,

    Here goes. Please be gentle on my coding techniques. It may not be pretty, but she works.

    I got the routine to export to a hard coded text file. It also looks for any user defined blocks as arrow heads and adds them to the beginning of the export file.


    ;| Steve Doman 07-05-04 beta
    Given a parent dimstyle name, returns a list of dimvars
    for each child style in the dimension style family

    Modified by Robert Good
    - added dialog interface for selecting dimstyle to export
    - added functionality to export parent and child dimstyle settings to a text file.

    |;


    (defun ExportDim ( / thedimstyles theList acadDocument dat Dimsel saved collection pat name namelist arrowlist var varlist val fp)
    (vl-load-com)
    (setq theList '()
    acadDocument (vla-get-activedocument (vlax-get-acad-object))
    thedimstyles (vla-get-dimstyles acadDocument)
    saved (vla-get-activedimstyle acadDocument)
    collection (vla-get-dimstyles acadDocument)
    ) ;_ end of setq

    ;;Create list with only dimstyle names without the $ sign
    (vlax-for item thedimstyles
    (if (not (vl-string-search "$" (vla-get-name item))) ;_verifies no $ in dimstyle name
    (setq theList (append theList (list (vla-get-name item))));_ add to list
    ) ;_end if
    ) ;_end vlax-for


    ;; Here we open a dialog box so the user can select the dimstyle
    ;; they want to save to an external file

    (setq dat (load_dialog "LandQ.dcl"))
    (if (not (new_dialog "SelectDimStyle" dat))
    (exit)
    ) ;_ end of if

    (action_tile "DimPop" "(setq DimSel $value)")
    (action_tile "accept" "(done_dialog 1)")

    (start_list "DimPop" 1)
    (mapcar 'add_list theList)
    (end_list)

    (start_dialog)
    (unload_dialog dat)


    (setq parent (strcase (nth (atoi DimSel) theList)))

    (setq pat (strcat parent "," parent "$[023467]")) ;_ for wcmatch

    ;; Make a list of each child style in dimstyle family
    (vlax-for itm collection
    (setq name (strcase (vla-get-name itm)))
    (if (wcmatch name pat)(setq namelist (cons name namelist)))
    ) ;_ end of vlax-for


    ;; The following list of dimvars may need to be adjusted cause
    ;; I haven't checked them over yet.
    (setq varlist (list "DIMADEC" "DIMALT" "DIMALTD" "DIMALTF" "DIMALTRND"
    "DIMALTTD" "DIMALTTZ" "DIMALTU" "DIMALTZ" "DIMAPOST"
    "DIMASO" "DIMASSOC" "DIMASZ" "DIMATFIT" "DIMAUNIT"
    "DIMAZIN" "DIMBLK" "DIMBLK1" "DIMBLK2" "DIMCEN"
    "DIMCLRD" "DIMCLRE" "DIMCLRT" "DIMDEC" "DIMDLE"
    "DIMDLI" "DIMDSEP" "DIMEXE" "DIMEXO" "DIMFRAC"
    "DIMGAP" "DIMJUST" "DIMLDRBLK" "DIMLFAC" "DIMLIM"
    "DIMLUNIT" "DIMLWD" "DIMLWE" "DIMPOST" "DIMRND"
    "DIMSAH" "DIMSCALE" "DIMSD1" "DIMSD2" "DIMSE1"
    "DIMSE2" "DIMSHO" "DIMSOXD" "DIMTAD" "DIMTDEC"
    "DIMTFAC" "DIMTIH" "DIMTIX" "DIMTM" "DIMTMOVE"
    "DIMTOFL" "DIMTOH" "DIMTOL" "DIMTOLJ" "DIMTP"
    "DIMTSZ" "DIMTVP" "DIMTXSTY" "DIMTXT" "DIMTZIN"
    "DIMUPT" "DIMZIN"
    ) ;_ end of list
    ) ;_ end of setq

    (setq arrowList (list "" "." "ArchTick" "ClosedBlank" "Closed" "Dot"
    "Oblique" "Open" "Origin" "Origin2" "Open90"
    "Open30" "DotSmall" "DotBlank" "Small" "BoxBlank"
    "BoxFilled" "DatumBlank" "DatumFilled" "Integral" "None"
    ) ;_ end of list
    ) ;_ end of setq


    ;; Set each child style active and collect dimvars
    (setq fp (open "d:\\dwg\\support\\lisp\\tempsettings.txt" "w"));_open file for writing

    (foreach name (reverse namelist)
    (vla-put-activedimstyle acadDocument (vla-item collection name))

    ;;here we write dimstyle header suffix information to file
    (write-line (strcat "**" name) fp)

    (foreach var varlist
    (setq val (getvar var))

    ;;here lets test for dimblk, dimblk1, dimblk2 and dimldrblk, if not standard autocad symbols
    ;;we need to save to and list to write to an external file which we will merge with the dimsettings text file
    (if (or (= var "DIMBLK")
    (= var "DIMBLK1")
    (= var "DIMBLK2")
    (= var "DIMLDRBLK")
    ) ;_End Or
    (if (and (not (member val arrowlist))
    (not (member val userArrows))
    );_end and
    (setq userArrows (append userArrows (list val)))
    ) ;_end if
    ) ;_ end of if

    (if (and (= (type val) 'STR) (= val ""))(setq val ".")) ;_ if string is empty, add dot.
    (write-line (vl-prin1-to-string (cons var val)) fp) ;_write to file
    ) ;_ end of foreach
    ) ;_ end of foreach

    (close fp) ;_close text file

    ;;write user arrows to an external file and merge with dimstyle text file
    (if userArrows
    (progn
    (setq fp (open "d:\\dwg\\support\\lisp\\dimsettings.txt" "w")
    ) ;_open file for writing
    (write-line (strcat "***" (vl-prin1-to-string userarrows)) fp)
    (close fp) ;_close text file
    (vl-file-copy ;_copy temp dim settings to final file
    "d:\\dwg\\support\\lisp\\tempsettings.txt"
    "d:\\dwg\\support\\lisp\\dimsettings.txt"
    T
    ) ;_ end of vl-file-copy
    (vl-file-delete "d:\\dwg\\support\\lisp\\landq routines\\tempsettings.txt") ; _ delete temp file

    ) ;_end progn
    ) ;_end if

    ;; restore active dimstyle
    (vla-put-activedimstyle acadDocument saved)

    ) ;_ end of defun


    Robert Good
     
    rgood, Jul 14, 2004
    #16
  17. Robert Good

    Steve Doman Guest

    Nice work Robert!

    Your coding techniques look fine. I appreciate that you have my name in
    the credits, but it's more your routine than mine. If you post the DCL
    file, I (we) can actually run the code. :)

    Regards,
    Steve Doman


    <clip>
     
    Steve Doman, Jul 15, 2004
    #17
  18. Robert Good

    rgood Guest

    Here is the dcl snip. Again Its not pretty. I need to spend some time beautifying the interface.

    SelectDimStyle : dialog {
    label = "Dimension Style Selection";
    : text {
    label = "Select the Dimension Style";
    alignment = centered;
    }
    : row {
    : popup_list {
    key = "DimPop";
    width = 10;
    //alignment = centered;
    //value = "0";
    }
    }
    spacer;
    ok_only;
    }

    }

    Robert Good.
     
    rgood, Jul 15, 2004
    #18
  19. Robert Good

    GaryDF Guest

    You had one too many }
    Also a list box would be easier to read.

    SelectDimStyle : dialog {label = " Dimension Style Selection";
    :text {label = "Select the Dimension Style"; alignment = centered;}
    :row {
    :list_box {key = "DimPop"; width = 10;}
    }
    spacer;
    ok_only;
    }

    Gary
     
    GaryDF, Jul 15, 2004
    #19
  20. Robert Good

    Steve Doman Guest

    Robert,

    Got it rolling! Had to delete the last curly brace in the DCL code
    posted, as Gary noted. Also had to change the output filename path to
    something local like "c:\\".

    I'm curious as to what your are doing with those Dimblk vars. I see
    that your code appends a list of user defined dimblks to the end of the
    output file. My guess is that later, during the importing of dimstyles
    into a drawing, you are inserting the blocks if they are not defined.

    Thanks,
    Steve Doman
     
    Steve Doman, Jul 16, 2004
    #20
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.
Similar Threads
There are no similar threads yet.
Loading...