How obtain the *.bmp from *.dwg with Visual Lisp

Discussion in 'AutoCAD' started by freeflyair, Jan 12, 2005.

  1. freeflyair

    freeflyair Guest

    First,I draw a dwg picture in AutoCAD with Visual Lisp language.
    Secondly,I want to transit the picture to bmp with Visual Lisp.
    Who know the way?Please tell me.
    Thank you .
    lily
     
    freeflyair, Jan 12, 2005
    #1
  2. freeflyair

    Jürg Menzi Guest

    Hi Lily

    Code:
    (vla-Export
    (vla-get-ActiveDocument (vlax-get-acad-object))
    "C:\\Temp\\MyPicture" "BMP"
    SelectionSet
    )
    
    For how to create a VisualLISP selection set visit my homepage -> Free Stuff
    and search for 'VxSsetSelect'.

    Cheers
     
    Jürg Menzi, Jan 12, 2005
    #2
  3. freeflyair

    stephen4444 Guest

    Hi Jurg,
    would this also work if you want to wblock a detail to a specific directory?
    Can you rewrite it as a completed lsp?
    Thanks.
     
    stephen4444, Jan 12, 2005
    #3
  4. freeflyair

    Jürg Menzi Guest

    Hi stephen4444
    Yes, but you've to use the wblock method. To export all formats, use
    MeExportAs (and the subs):
    Code:
    ;
    ; -- Function MeExportAs
    ; Exports a selection set in the format by 'Typ' argument.
    ; Copyright:
    ;   ©2005 MENZI ENGINEERING GmbH, Switzerland
    ; Arguments [Type]:
    ;   Fil = File path and name (without extension) [STR]
    ;   Typ = Export type (wmf, sat, eps, dxf, dwg, or bmp) [STR]
    ;   Sst = Selection set (nil for eps or dxf) [PICKSET]
    ; Return [Type]:
    ;   > Null
    ; Notes:
    ;   - For eps and dxf formats, the selection set is ignored and the
    ;     entire drawing is exported
    ;   - Overwrites existing files without warning
    ;
    (defun MeExportAs (Fil Typ Sst / AcaDoc TmpSet)
    (vl-load-com)
    (setq AcaDoc (vla-get-activedocument (vlax-get-acad-object))
    TmpSet (MeSsetMake AcaDoc "MeTempSet")
    )
    (if Sst (vla-AddItems TmpSet (MeSset2ObjArr Sst)))
    (if (eq (strcase Typ) "DWG")
    (vla-Wblock AcaDoc (strcat Fil "." Typ) TmpSet)
    (vla-Export AcaDoc Fil Typ TmpSet)
    )
    (princ)
    )
    ;
    ; == Function MeSset2ObjArr
    ; Converts a selectionset to an array of objects.
    ; Copyright:
    ;   ©2002 MENZI ENGINEERING GmbH, Switzerland
    ; Arguments [Type]:
    ;   Sst = Selectionset [PICKSET]
    ; Return [Type]:
    ;   > Array of objects [VARIANT]
    ; Notes:
    ;   - None
    ;
    (defun MeSset2ObjArr (Sst / CurEnt ObjLst)
    (while (setq CurEnt (ssname Sst 0))
    (setq ObjLst (cons (vlax-ename->vla-object CurEnt) ObjLst))
    (ssdel CurEnt Sst)
    )
    (vlax-make-variant
    (vlax-safearray-fill
    (vlax-make-safearray vlax-vbObject (cons 0 (1- (length ObjLst))))
    (reverse ObjLst)
    )
    )
    )
    ;
    ; -- Function MeSsetMake
    ; Creates a new selection set or clears an existing one.
    ; Copyright:
    ;   ©2002 MENZI ENGINEERING GmbH, Switzerland
    ; Arguments [Type]:
    ;   Acd = Document object [VLA-OBJECT]
    ;   Nme = Selection set name [STR]
    ; Return [Type]:
    ;   > Empty selection set [VLA-OBJECT]
    ; Notes:
    ;   - None
    ;
    (defun MeSsetMake (Acd Nme / SetCol)
    (setq SetCol (vla-get-SelectionSets Acd))
    (if (vl-catch-all-error-p
    (vl-catch-all-apply 'vla-add (list SetCol Nme))
    )
    (vla-clear (vla-Item SetCol Nme))
    )
    (vla-Item SetCol Nme)
    )
    
    Sample:
    (MeExportAs "C:\\Temp\\ExportTest" "dwg" (ssget))

    Cheers
     
    Jürg Menzi, Jan 13, 2005
    #4
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.