Code Red > AutoLISP (Vanilla / Visual)

A routine to select objects and DXF them transparently.

(1/1)

Tramber:
Hi everybody !

I've been trying to make a routine but it doesn't work very well.
At the end, the exported document that I saved as a DXF12 doesn't close in spite of my efforts.

The code is there :
(the APA-.... commands come from a routine collection that I ever used but that I'm not able to write in plain Vlisp, I'm sorry because it will be hard for anyone who wants to help directly on my code)


--- Code: ---(defun exdxf()
  (if(not APMODELSPACE)(apax-init))
  (apax-init)
  (setq oldapThisDrawing apThisDrawing)
  (SSsETFIRST nil)
  (setq ssetObj (apa-get-ActiveSelectionSet apThisDrawing))
  (apa-Clear ssetObj)
  (setq filter nil)
  (apa-SelectOnScreen ssetObj nil)
  (apa-get-Count ssetObj)
  (setq sauvdoc apThisDrawing)
  (setq chemine(getvar"dwgprefix"))
  (dos_mkdir (strcat chemine "Commandes\\"))
  (apa-WBlock apActiveDocument (strcat chemine "Commandes\\exporttest") ssetObj)
  (apa-SaveDocument apThisDrawing)
  (setq notredessin (apa-open apDocuments (strcat chemine "Commandes\\exporttest" ".dwg") nil))
  (vla-activate notredessin)
  (apa-SaveAs notredessin (strcat chemine "Commandes\\exporttest") acR12_DXF) 
  (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "_.CLOSE ")
  (vla-activate oldapThisDrawing)
  )
--- End code ---


The problem is that the exporttest.dwg doesn't want to close.
The question is : do you know any weblink that I could follow to read about similar problems ?

Thanks in advance.

Sdoman:
Your code is difficult to follow with having the subroutines.  But if you want to dxf out a selection set, use can simply use something like:

--- Code: ---(command  ".dxfout"  filename  "ver"   "r12"  "objects"  ss ""  "preview"  "no"  "16"  )

--- End code ---

If on the other hand you are trying to run the code while switching the active drawing, I've read that you can't do that in LISP.  Perhaps you can with VBA, I dunno.
 
 
 
 

Tramber:
STUPID !

That's how I feel....

By still thinking in Vlisp, you forget your native language.

I should have thought of DXFOUT, it is so simple.   :kewl:

Sdoman:
Been there.  Done that, thousands of times  : )

One of our duties were I work is to do CNC programming.  Therefore we often need to export selected objects from a submittal drawing to a DXF file.  I wrote a little LISP routine to speed the process of DXFing out objects. 

The routine prompts the user for a selections set, a basepoint, and a DXF file name.  It copies the selection from the basepoint to the drawing's XYZ origin.  Then it explodes any blocks in the selection set because blocks are not good when imported into our CAM software.  Finally the routine DXF's out the whole mess to file. This makes a DXF file with the selected basepoint as the DXF file origin.  I can post code if you're interested.

Tramber:
That's very kind of you.
I must say that the base point problem is already solved with the help of a
--- Code: ---(acet-geom-ss-extents sset t)
--- End code ---

But I also have to programm some explosions and would be interested.

Do you explode in a model where stand other entities or do you need to export the entire database of the drawing ?
I myself must export a selection set from a general drawing containing other entities.

On the other hand, I must also export as 2004 DWG but would like to export 2000. What a mess, it becomes necessary to open, saveas and close. Therefore, I must deal with multiple SDI-MDI configurations at my office....
If I don't succed, I'll post here  :wink:

Navigation

[0] Message Index

Go to full version