Export selection/ fixed view to DWG file
Good evening,
I'm developing a parametric drawing for elevators scheme using ODCL.
I need to export a fixed part or the drawing to a DWG file in order to view it inside an ODCL dialog.
How can I do it?
Thanks a lot for any reply
Marco
0
Comments
-
[..] I need to export a fixed part *of the drawing [..]0
-
Instead of doing something as complicated as exporting part of a drawing, although this can be done, I would first look at the BlockView control and the BlockView-PreLoadDwg method. This method will allow you to display blocks from another drawing. This means that all you would have to do is create a block from the 'fixed part' which you may need anyway.
[code](setvar 'cmdecho 0)
(command "_.Opendcl")
(setvar 'cmdecho 1)
(defun c:Test ( / c:BlkViewTest/Form1#OnInitialize)
(defun c:BlkViewTest/Form1#OnInitialize (/)
(dcl-BlockView-PreLoadDwg BlkViewTest/Form1/BlockView1 "BlkViewTest.dwg")
(dcl-Control-SetBlockName BlkViewTest/Form1/BlockView1 "circ")
(dcl-BlockView-Zoom BlkViewTest/Form1/BlockView1 0.9)
)
(dcl-Project-Load "BlkViewTest" T)
(dcl-Form-Show BlkViewTest/Form1)
)[/code]0 -
Thank you Roy.Your solution worked with a statical drawing.The problem now is that I have to show some drawings that are dinamically created via lisp code.There is a way to generate drawing and assing each component to a block?Marco0
-
Your use of the word 'fixed' is then confusing...
I also do not know what you mean by 'component'.
Here is some code to demonstrate creating a dwg with a block definition 'on the fly':
[code](setvar 'cmdecho 0)
(command "_.Opendcl")
(setvar 'cmdecho 1)
(defun c:Test ( / c:BlkViewTest/Form1#OnInitialize docNme)
(defun c:BlkViewTest/Form1#OnInitialize (/)
(dcl-BlockView-PreLoadDwg BlkViewTest/Form1/BlockView1 docNme)
(dcl-Control-SetBlockName BlkViewTest/Form1/BlockView1 "circ")
(dcl-BlockView-Zoom BlkViewTest/Form1/BlockView1 0.9)
)
(setq docNme (CreateDwgWithBlock))
(dcl-Project-Load "BlkViewTest" T)
(dcl-Form-Show BlkViewTest/Form1)
(vl-file-delete docNme)
(princ)
)
(defun CreateDwgWithBlock ( / blkDefObj docNme docObj)
(setq docNme (vl-filename-mktemp ".dwg"))
(setq docObj
(vla-getinterfaceobject (vlax-get-acad-object) "objectdbx.axdbdocument")
)
(setq blkDefObj (vla-add (vla-get-blocks docObj) '(0.0 0.0 0.0) "circ"))
(vla-addcircle blkDefObj '(0.0 0.0 0.0) 10.0)
(vla-addcircle blkDefObj '(0.0 0.0 0.0) 30.0)
(vla-saveas docObj docNme acnative)
(vlax-release-object docObj)
docNme
)[/code]0 -
with "fixed part of the drawing" I mean the part of a drawing statically identified by a rectangle.with "component" I mean each line,rectangle and text that compose the drawing.The problem in my case is that the "interesting part" of the drawing is defined in a very complicate third part lisp routine.Select the components via rectangle and export that selection in a temporary DWG I'm afraid that is the only way to solve my problem.After the generation of the drawing i will load it in a blockview control via preloaddwg function.I attach an example DWG.Suppose the part to export is the rectangle with the star in the drawing.Thank youMM0
-
The EXPORTLAYOUT command (new in V16) exports the content of a layout viewport to a new drawing. Please notice the exported geometry is scaled by the Viewport's 'Custom Scale'. The drawing is clipped by the viewport borders.0
-
@ Marco:
Here is some Lisp code demonstrating the creation of a temporary dwg with a block definition containing entities copied from a source dwg.
In the code the srcObjLst is not yet 'filtered' based on a rectangular window. You will have to do that yourself. You can use vla-getboundingbox or vle-getboundingbox to determine the boundingbox of entities and then check if they fall inside the desired rectangle.
[code](defun _Sys_ApplyAlt (expr varLst)
(not (vl-catch-all-error-p (vl-catch-all-apply expr varLst)))
)
(setvar 'cmdecho 0)
(command "_.Opendcl")
(setvar 'cmdecho 1)
(defun c:Test ( / c:BlkViewTest/Form1#OnInitialize docNme)
(defun c:BlkViewTest/Form1#OnInitialize (/)
(dcl-BlockView-PreLoadDwg BlkViewTest/Form1/BlockView1 docNme)
(dcl-Control-SetBlockName BlkViewTest/Form1/BlockView1 "TMP")
(dcl-BlockView-Zoom BlkViewTest/Form1/BlockView1 0.9)
)
(if (setq docNme (CreateDwgWithBlockFromSource (findfile "example.dwg")))
(progn
(dcl-Project-Load "BlkViewTest" T)
(dcl-Form-Show BlkViewTest/Form1)
(vl-file-delete docNme)
)
(princ "\nError: cannot open dwg ")
)
(princ)
)
(defun CreateDwgWithBlockFromSource (srcDocNme / srcDocObj srcObjLst trgDocNme trgDocObj)
(setq srcDocObj
(vla-getinterfaceobject (vlax-get-acad-object) "objectdbx.axdbdocument")
)
(setq trgDocObj
(vla-getinterfaceobject (vlax-get-acad-object) "objectdbx.axdbdocument")
)
(if
(and
(_Sys_ApplyAlt 'vla-open (list srcDocObj srcDocNme))
(setq srcObjLst (cdr (vle-collection->list (vla-get-modelspace srcDocObj))))
)
(progn
(vlax-invoke
srcDocObj
'copyobjects
srcObjLst
(vla-add (vla-get-blocks trgDocObj) '(0.0 0.0 0.0) "TMP")
)
(setq trgDocNme (vl-filename-mktemp ".dwg"))
(vla-saveas trgDocObj trgDocNme acnative)
)
)
(vlax-release-object srcDocObj)
(vlax-release-object trgDocObj)
trgDocNme
)[/code]0
This discussion has been closed.