Author Topic: Problem with some regions exploded from 3d-bodys processed with Superflatten  (Read 13471 times)

0 Members and 1 Guest are viewing this topic.

peterba

  • Guest
Hello all,

this is my first post here.
I live in Germany and i hope my English is not to bad.
I use lisp since a long time and solved some problems in autocad with it.
I found Superflatten 1.1a anywhere a few months ago and after some checks i mention that it is the best program around.
Thank you Joe for this exceptional program.

Now i noticed, that there is a new release 1.2e. I inspected the code and made some tests with drawings in autocad.
I fixed some lines for use in local autocad versions and added an error control in function "FlatRegion".
You find the lines marked as:
Quote
;; *** Modification by pb

My test drawing "Pumpe1.dwg" contains one 3DSOLID. With my changes superflatten processes without any error but leaves some objects unflattened.
The other point is, that some flattended parts have lost details (for instance border lines).
(AutoCAD 2009)

Hope, somebody can give a suggestion.

kind regards
Peter B.

Joe Burke

  • Guest
Hi Peter,

Welcome to theswamp. Your English sounds good to me.

I'm glad to hear you found SuperFlatten useful.

I haven't studied your code changes or example file yet, but I will over the weekend.

Regards
Joe Burke

Joe Burke

  • Guest
Peter,

I looked at the internationalization changes you made. Good catch. I thought all of that had been caught before, but obviously not. I will issue a new version which includes those changes.

Regarding your change to the FlatRegion sub-function, agreed, it avoids a potential error given your example file. I will incude your changes in the next version with credit to you for those changes.

Obviously SF is a very complicated routine. I've often thought it's strange I've received no problem reports similar to yours.

At the same time, the routine has always worked well for me when dealing with the types of files which it was designed to fix.

More later...


Joe Burke

  • Guest
Peter and admin folks,

I've updated the code per Peter's bug report to SuperFlatten version 1.2f, but I'm not sure where to post it. The original SF topic started by me is in Show Your Stuff. There is also a SuperFlatten topic in AutoLISP (Vanilla / Visual) where I posted revised versions.

Should these two topics be combined? Plus we have this new related topic by Peter. Please advise.
« Last Edit: November 27, 2010, 06:44:17 AM by Joe Burke »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>

I'd post the 'f' build in Show your stuff but leave the prev build there ie just add the new zip attachment in the first post.
Then I'd add a note/link to S.Y.S.  in any other posts that have a build.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Joe Burke

  • Guest

I'd post the 'f' build in Show your stuff but leave the prev build there ie just add the new zip attachment in the first post.
Then I'd add a note/link to S.Y.S.  in any other posts that have a build.


Hi Kerry,

I'd prefer to have all messages related to the routine moved to the original topic in Show Your Stuff. The header comments within the routine point there.

;; Please send bug reports to me directly at lowercase@hawaii.rr.com
;; or post to the SuperFlatten topic at theswamp under "Show your stuff".

Obviously if the rouine is posted elsewhere, there should be only one place to look here for the latest version.

Likewise, older versions should not be available here.
« Last Edit: November 29, 2010, 06:10:20 AM by Joe Burke »

peterba

  • Guest
Hi Joe,

thank you for reply - and the nice words  :wink:

I agree with you that there should be only one location to store and find the newest version of SF.
But I'm new here an will follow your rules.

Until now, the problem like in the sample file (Pumpe.dwg) only rarely occurs. But this 3D solid object is only a little part of a larger 3D plant design.
Most of the body objects lose details after "SF" because of the internal use of "explode".
I have played around with the express tools "flatten" and noticed that the method used there (WMF out/in) gives me a better result for the 3D objects.
Therefore i included the call to the ET sub-function "acet-wmf-convert"  in your Superflatten and a few additional code for handy use.

I'd like to show you my draft of this version. But how? Just another attachment or personal message?

Peter

Joe Burke

  • Guest
Hi Peter,

I guess you should post your WMF in/out code in this topic for now so others who may be interested can test it. Where the current SF version ultimately resides can be left to future discussion.

You are probably aware the WMF in/out method tends to loose accuracy. I reserve judgement until I test your code.

Thanks for your help.

Joe Burke

  • Guest
Peter,

Attached is an example file of the types of problems SF was originally designed to fix. How it deals with the types of objects you mentioned was an after-thought, simply intended to make the routine more complete.

Joe Burke

  • Guest
Also, try running ET flatten command on the exmple file. It fails/errors due to some poor code.

peterba

  • Guest
Joe,
attached is your SF with my code parts: marked with "*** Modification by pb"

the main altered parts are:
Code: [Select]
  ;; *** Modification by pb ***
  ;; new function for 3D objects
  ;; if Expresstools loaded use WMFout/in in acet-wmf.lsp
  (defun Flat3D (obj / ss)
    (if acet-wmf-convert
      (progn
(princ
  (strcat "\rEinebnen der Auswahl (Element: "
  (substr objname (+ 3 (vl-string-search "Db" objname)))
  "), bitte warten... "
  (setq *sbar (Spinbar *sbar))
  "\t"
  )
)

;; save the original view
(if (not (tblsearch "view" "zztemp"))
  (progn
    (command "._view" "_s" "zztemp")
    (command "._ucs" "_w")
  )
)
;; set to top view without perspective
(setvar "perspective" 0) ;Parallelansicht = ohne Perspektivansicht
(command "._view" "_o" "_t")

;; Definiert ein neues Koordinatensystem, dessen XY-Ebene senkrecht
;; zur Blickrichtung liegt (parallel zum Bildschirm).
;; (acet-ucs-cmd (list "_view"))
 
;;Parameter für WMFout/in
;; 3= scale each object to max size possible before wmf
(setq ss (acet-wmf-convert
   (list (ssadd (vlax-vla-object->ename x)) 3 nil nil)
)
)

(if ss
  (progn
    ;; flatten was succesful
    ;; kill source object
    (vla-delete obj)
    ;; Idee:
    ;; Neuen Auswahlsatz in neuem Block zusammenfassen
    ;; Objekttyp + "_flattend_" + "Objektname
    ; .....
  )
  ;; if not succesful, try explode
  (CommandExplode x)
)
;; set previous coordinate system
(acet-ucs-cmd (list "_p"))
      )
      ;; do explode in case of ET not loaded
      (CommandExplode x)
    )
  ) ; _end of new function Flat3D *** Modification by pb

call of Flat3D:
Code: [Select]
           ((or
       (eq "AcDb3dSolid" objname)
       (eq "AcDbSurface" objname)
     )

      ;; *** Modification by pb ***
      ;; new function Flat3D - use WMFout/in
      ;; (more details but less precision than CommandExplode)
      ;; maybe add a condition with user decision wich
      ;; method preferable
      (Flat3D x)

    )
load ET helper function:
Code: [Select]
;; *** Modification by pb ***
;; In the case of Expresstools installed, use WMFout/in in acet-wmf.lsp
(if (findfile "acet-wmf.lsp")
  ;;(load "acet-wmf.lsp" "Konnte ET-Hilfsprogramm nicht laden!")
  (princ (load "acet-wmf.lsp" "Could not load help function of Expresstools!"))
)
(princ)
... and some variables save and restore

I tried it on your file without errors. because therein are not 3dsolid objects?
Program message: "Number of objects in model space before: 23581 after: 23579"
Result looks flattend as expected.

I know that ET flatten crashes in some files.
To avoid this i implemented only the subfunction "acet-wmf-convert". This function makes something else that i don't understand and takes some longer time, but it works fine for me.

Improvements could be:
- a user question, which method to use for 3d objects
  decide:  Explode with the risk of loosing details OR WMFout with loosing precision
- include the code for WMFout/in similar to the ET function "acet-wmf-convert" without extra subroutines

Joe Burke

  • Guest
Hi Peter,

I will need some time to study your WMFIn/Out suggestion. At first glance, using your Pump example file for testing, it looks like an excellent idea. The fact some precision is lost in the process is far outweighted by the fact data is not lost and everything is flattened, unlike the current SF version which uses the explode command.

Question, what version of ACAD are you using? I'm using vanilla 2008. In 2008 the WMFIN and WMFOUT calls are native ACAD commands. IOW, ExpressTools is not required. I don't know when these commands moved from ET to ACAD. The ExpressTools folder within 2008 still contains the acet-wmf.lsp routine your code calls.

Just food for thought at this point...

I agree there should be an option presented to the user to use WMF or explode when these types of objects are involved. As you probably know, the routine already does some checking up front to determine what types of objects were selected, before it processes the objects.

BTW, speed is not an issue in my nind. It may take a very long time to process deep nested blocks as is.

Thanks
« Last Edit: December 01, 2010, 08:27:07 AM by Joe Burke »

peterba

  • Guest
Hi Joe,
I'm using pure ACAD 2009. You' right: the Commands WMFIN and WMFOUT are build in.
I think these commands where not an invention of ExpressTools but they are used within their programmes.

The essence of ET function "acet-wmf-convert" seems to be "acet-wmf-round-trip" with the lines:
Code: [Select]
(acet-safe-command T T (list "_.wmfout" tmp ss ""))
...
(acet-safe-command T T (list "_.wmfin" tmp x "2" "2" "0"))
tmp=temporary file name
ss=current selection set
x=insert point (of the ss?)
This could be done with (command _.wmfout ...) in the same manner (filedia=0!) while rejecting the ET functions.

I'm afraid of some more questions to solve. I understand that you need more time to explore the WMFout/in method and would be very happy if you find a working release. In the meantime i can use the modified SF.
Perhaps somebody can help...

Nevertheless many thanks for your assistance.

Joe Burke

  • Guest
Hi Peter,

I think the WMFOUT and WMFIN commands have been around for a long time.

I would prefer as little reliance on acet functions as possible because old ACAD versions (2002?) did not ship with ExpressTools. Plus there's the possibilty with recent versions that the user chose not to install ET for some reason.

Looking at the code, I'm reminded of the Flatshot command which was new in ACAD 2007. Check this link which explains the Flatshot and XEdges commands.

http://www.autodeskpress.delmar.cengage.com/resources/olcs/acad2007/feb07/

Of course the Flatshot command cannot be called within SuperFlatten because there's a dialog involved and no command line version of the command. I just mention it because I'd probably use it to flatten 3DSolid objects when full accuracy is a concern.

Also note the ActiveX Export and Import methods. I haven't tried them, but Export can export a selection set of objects to a WMF file according to the documentation.

Regards

peterba

  • Guest
I have played with a new function for WMFout and WMFin for use as an alternative flatten method:
(it's the first draft)
Code: [Select]
;;; WMFTest.lsp
;;;
;;; Description:
;;; 1.) user selects the objects in current view
;;; 2.) export selection in temporary WMF
;;; 3.) import WMF as flat block reference on same position but with Z=0
;;;
;;; Intention: new WMFout/in help function for J.B.s SuperFlatten
;;;
(defun C:WMFtest ( / doc ss-name ss tmp tmpwmf targetpnt width height inspnt blkref)

  (VL-LOAD-COM)
 
  ;; Dokument
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))

  ;; Auswahlsatz
  (setq ss-name "WMFtest_ss")
  ;; kill last selection if exist
  (if (not (vl-catch-all-error-p
     (setq ss (vl-catch-all-apply
'vlax-invoke-method
(list (vla-get-SelectionSets doc) 'Item ss-name)
      )
     )
   )
      )
    (vla-Delete ss)
  )
  ;; create VLA-SelectionSet and add user selection
  (setq ss (vlax-invoke-method (vla-get-SelectionSets doc) 'Add ss-name))
  (vla-SelectOnScreen ss)

  (if (< 0 (vla-get-count ss))
    ;; selection set is not empty
    (progn
      ;; get a temp filename
      (setq tmp    (vl-filename-mktemp nil nil nil) ;without extension
    tmpWMF (strcat tmp ".WMF")
      )

      ;; WMFout
      ;; automatic generation of insertion point: top left corner of view???
      (vlax-invoke-method doc 'Export tmp "WMF" ss)

      ;; Not sure how to generate the correct insertion point for import???
      ;;
      ;; trying with the target coordinates of the current viewport...
      (setq targetpnt (vlax-safearray->list ;gibt eine Koordinatenliste zurück
(vlax-variant-value ;holt Safearray aus Variant
  (vla-get-Target (vla-get-ActiveViewport doc))
)
      )
      )
      (setq width (vla-get-Width (vla-get-ActiveViewport doc))) ;Fensterbreite
      (setq height (vla-get-Height (vla-get-ActiveViewport doc))) ;Fensterhöhe

      [color=red];; generate Safearray for insertion point
      (setq inspnt (vlax-make-safearray vlax-vbDouble '(0 . 2)))

      ;; calculate coordinates for new insertion: top left corner
      ;; ??? how do this ???
      (vlax-safearray-put-element inspnt 0 (- (car targetpnt) (/ width 2)))
      (vlax-safearray-put-element inspnt 1 (+ (cadr targetpnt) (/ height 2)))
      (vlax-safearray-put-element inspnt 2 0) ;setzt Z=0
      (setq inspnt (vlax-make-variant inspnt)) ;macht Variant aus Safearray[/color]

      ;; WMFin
      (if (findfile tmpWMF)
(progn
  (setq blkref (vla-Import doc tmpWMF inspnt 2))
  (vl-file-delete tmpWMF)
)
      )
    )
  )

  ;; delete selection set - but not the objects
  (vla-Delete ss)
 
  (princ)
)
It should insert the WMF file objects at the same position as the selection set from where it was created.
But it don't works - see the red code above!

You can try it with any drawing or with the attached file.
Any suggestions?

Greets ... and have a nice weekend!

ghostware

  • Guest
Flatshot standard Autocad command...
Convert a 3D solid to a 3-view 2D drawing in model space.
When you have 3D solids and regions drawings you can flat them to 2D views by using the command FLATSHOT.
It will create 2D representations

Read more: http://www.ellenfinkelstein.com/AutoCAD_tips_3D-2D_model_space.html#ixzz175MI0dqx


Joe Burke

  • Guest
I have played with a new function for WMFout and WMFin for use as an alternative flatten method:
(it's the first draft)
Code: [Select]
;;; WMFTest.lsp
;;;
;;; Description:
;;; 1.) user selects the objects in current view
;;; 2.) export selection in temporary WMF
;;; 3.) import WMF as flat block reference on same position but with Z=0
;;;
;;; Intention: new WMFout/in help function for J.B.s SuperFlatten
;;;
(defun C:WMFtest ( / doc ss-name ss tmp tmpwmf targetpnt width height inspnt blkref)

  (VL-LOAD-COM)
  
  ;; Dokument
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))

  ;; Auswahlsatz
  (setq ss-name "WMFtest_ss")
  ;; kill last selection if exist
  (if (not (vl-catch-all-error-p
    (setq ss (vl-catch-all-apply
'vlax-invoke-method
(list (vla-get-SelectionSets doc) 'Item ss-name)
     )
    )
  )
      )
    (vla-Delete ss)
  )
  ;; create VLA-SelectionSet and add user selection
  (setq ss (vlax-invoke-method (vla-get-SelectionSets doc) 'Add ss-name))
  (vla-SelectOnScreen ss)

  (if (< 0 (vla-get-count ss))
    ;; selection set is not empty
    (progn
      ;; get a temp filename
      (setq tmp   (vl-filename-mktemp nil nil nil) ;without extension
   tmpWMF (strcat tmp ".WMF")
      )

      ;; WMFout
      ;; automatic generation of insertion point: top left corner of view???
      (vlax-invoke-method doc 'Export tmp "WMF" ss)

      ;; Not sure how to generate the correct insertion point for import???
      ;;
      ;; trying with the target coordinates of the current viewport...
      (setq targetpnt (vlax-safearray->list ;gibt eine Koordinatenliste zurück
(vlax-variant-value ;holt Safearray aus Variant
 (vla-get-Target (vla-get-ActiveViewport doc))
)
     )
      )
      (setq width (vla-get-Width (vla-get-ActiveViewport doc))) ;Fensterbreite
      (setq height (vla-get-Height (vla-get-ActiveViewport doc))) ;Fensterhöhe

      [color=red];; generate Safearray for insertion point
      (setq inspnt (vlax-make-safearray vlax-vbDouble '(0 . 2)))

      ;; calculate coordinates for new insertion: top left corner
      ;; ??? how do this ???
      (vlax-safearray-put-element inspnt 0 (- (car targetpnt) (/ width 2)))
      (vlax-safearray-put-element inspnt 1 (+ (cadr targetpnt) (/ height 2)))
      (vlax-safearray-put-element inspnt 2 0) ;setzt Z=0
      (setq inspnt (vlax-make-variant inspnt)) ;macht Variant aus Safearray[/color]

      ;; WMFin
      (if (findfile tmpWMF)
(progn
 (setq blkref (vla-Import doc tmpWMF inspnt 2))
 (vl-file-delete tmpWMF)
)
      )
    )
  )

  ;; delete selection set - but not the objects
  (vla-Delete ss)
  
  (princ)
)
It should insert the WMF file objects at the same position as the selection set from where it was created.
But it don't works - see the red code above!

You can try it with any drawing or with the attached file.
Any suggestions?

Greets ... and have a nice weekend!

Peter,

I will study your post over the weekend.

Thanks for the attempt at making it work without acet calls.

If that proves too difficult, we use the acet stuff per your previous post.
« Last Edit: December 04, 2010, 07:17:56 AM by Joe Burke »

Joe Burke

  • Guest
Hi Peter,

Please check me on this.

While testing your SuperFlatten_1.2e_pb_useWMFout.lsp I commented out the line (vla-delete obj) within the Flat3D function so the source object passed to the function is not deleted. The test file was your Pump example file. I was trying to compare the original object to the WMFin/out result.

What I'm seeing does not look correct. The flattened objects are about 25.4 times larger than the source object (likely a metric/imperial units problem) plus the flattened objects are not in the same location as the source object.

Later... I checked the INSUNITS variable in the Pump file. It is set to 4 Millimemters. After changing it to 0 Unitless the above problem did not occur. So this is something the routine needs to check and adjust as needed.
« Last Edit: December 06, 2010, 04:07:27 AM by Joe Burke »

peterba

  • Guest
@Joe
I've just read your post but have no time today. i will check it tomorrow.

Edit:
I've tried several values for INSUNITS without any influence on flattening result.
Then I've found INSUNITSDEFSOURCE and INSUNITSDEFTARGET in acad help and asserted that different values (other than 0) produces similar results as you described above.
Please consider I'm not an acad designer. Only created some tools for other folks.
If it is necessary to adjust any variables in autocad please make accordant program changes.

@ghostware
thank you for the hint.
I know this command but you can use it "only" with the dialog window and not as a call in scripts or program functions.
« Last Edit: December 07, 2010, 07:53:49 AM by peterba »

Joe Burke

  • Guest
Peter,

Try this with your Pump example file when you have some time. Note, it assumes the view is Top WCS.

Code: [Select]
(defun c:WMFInOut ( / doc ename obj ss tmp tmpwmf srcctr blkref blkctr BBCenter)
  (vl-load-com)
  ;; Get bounding box center.
  ;; Argument: vla-object.
  (defun BBCenter (obj / mn mx)
    (vla-GetBoundingBox obj 'mn 'mx)
    (mapcar '*
      (mapcar '+ (vlax-safearray->list mn) (vlax-safearray->list mx))
        '(0.5 0.5 0.5)
    )
  )

  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (if
    (and
      (setq ename (car (entsel "\nSelect 3DSolid object: ")))
      (setq obj (vlax-ename->vla-object ename))
      (eq "AcDb3dSolid" (vlax-get obj 'ObjectName))
      (setq srcctr (BBCenter obj))
      (setq ss (ssadd))
      (setq ss (ssadd ename ss))
      ;; get a temp filename
      (setq tmp (vl-filename-mktemp nil nil nil))
      (setq tmpwmf (strcat tmp ".WMF"))
    )
    (progn
      ;; WMFout
      (sssetfirst nil nil)
      (sssetfirst nil ss)
      (vlax-invoke doc 'Export tmp "WMF" (vlax-get doc 'ActiveSelectionSet))
      ;; WMFin
      (if (findfile tmpwmf)
        (progn
         (setq blkref (vlax-invoke doc 'Import tmpwmf srcctr 2.0))
         (setq blkctr (BBCenter blkref))
         (vlax-invoke blkref 'Move blkctr srcctr)
         (vl-file-delete tmpWMF)
         ;; the source object is not deleted for comparison purposes.
         ;(vla-delete obj)
        )
      )
    )
  )
  (princ)
)
« Last Edit: December 07, 2010, 07:24:30 AM by Joe Burke »

peterba

  • Guest
curious behaviour: :|
sometimes perfect and sometimes there is a second user prompt "select objects"
i believe it stops here:
Code: [Select]
...
      ;; WMFout
      (sssetfirst nil nil)
      (sssetfirst nil ss)
      (vlax-invoke doc 'Export tmp "WMF" [color=red](vlax-get doc 'ActiveSelectionSet)[/color])
When pressing only "Enter" nothing happens.
If picking anything an unvisible WMFx Block is created.

Joe Burke

  • Guest
Peter,

Keep in mind, whatever quirks which may occur within the code I posted would be fixed when it's converted to a sub-function within SF. But that's a moot point...

Take a look at the file named 3D House.dwg in ACAD Samples folder. It contains many 3DSolid objects and some 2D objecs. I used that file while testing SF.

I change the file to top view and Visual Style 2D Wireframe. If I run the code I posted and select the 3DSolid table between the two couches, the result is not correct. The WMFIN block is wrong in terms of location and scale. I'm not inclined to investigate why given the following. If I run your version of SF with the Flat3D function and select all, the file is correctly flattened.

I'm not surprised to find the function I posted failed. I suspected it might given examples other than your example file. Junk that idea.

Another observation with that file. If I use the flatshot command and place a new block in the drawing, all 2D objects are not included in the new block. Example: the door swings are 2D arcs and lost in resulting flaltshot block.

There's a lot to think about here in terms of what SF should do and what options it should offer.

Also note, the current verion of SF flattens the 3DSolid objects in the 3D House file using (command "explode"). Of course it does not work well with your Pump example file.

My thoughts at this point are as follows. Use your Flat3D function as is. Probably removed the (command "explode") idea. And if any 3DSolid or similar objects are detected in SF selection set, including those in blocks, offer an option to exit SF and suggest the flatshot command given 2007 or later.
« Last Edit: December 08, 2010, 06:17:57 AM by Joe Burke »

Joe Burke

  • Guest
Peter,

Another thought in favor of using the ExpressTools WMF functions. My testing indicates the number of objects in the active file after processing is significanty less than what happens when using the ActiveX Export and Import methods.

peterba

  • Guest
Hi Joe,
I'm not sure, if i really understand everything you wrote (because of my less English skills).

Relating to your future release of SuperFlatten I would prefere a user decision about handling of 3D objects:
- flatten with explode as processed until now
- flatten with WMFout/in as discussed here (implementing the ExpressTools function "acet-wmf-convert" or a new function is your decision)
- ignore 3DSOLIDS (and SURFACE?) with a hint at the end of SF to use AutoCAD's "flatshot" command for best results

It should be "script-able" as it is now in SF with your global options.

But, don't investigate too much in this issue. It seems not to be a general problem to others.
I can work with your super program and the decision about flatten 3D objects can be done before with the selection set.

Joe Burke

  • Guest
Hi Peter,

I've had some time recently to get into issues you raised related to the use of WMF.

If you have some time and access to the "3D House" Autodesk example file in the Sample folder, please try running your version of the SF code on that file. When I do that, ACAD 2008 consistantly crashes with a fatal error when I try to save the file after the routine ends.

I've written a new WMFOutIn sub-function which seems to work well. It does not use acet functions and it does not cause a crash when saving as above. Plus it's faster than the acet based code. I'll post after I do more testing.

Regards

peterba

  • Guest
Hi Joe,
I'm glad to see you again in this topic.

I will check my program later with the "3D House.dwg" ...
I am using ACAD 2009.
(I have to work with other things this time)

so long!
Peter

-----------------------------------------------------------
EDIT 28.01.11 (My last notice at this place as you suggested)
Have checked my SF version (with WMFOutIn) on ACAD2009:

Number of objects in model space before: 266 after: 10875
Number of objects not processed or flattened: 7
Object types not flattened: Light

Then saved as new drawing (as acad 2007 type drawing) and opened with recover (16900 objects + 8 blocks) without any errors.

in conclusion: successful flattening but worked very long (about 20 minutes in my virtual machine)

will wait for your new optimized SF version...
« Last Edit: January 28, 2011, 10:53:44 AM by peterba »

Joe Burke

  • Guest
Peter,

Take your time with testing. There's no hurry.

You might also test the 3D House file with the current SF version 1.2e. I think you'll find it does a good job and fast given the types of 3DSolid objects in that file simply using command explode. Which in turn reinforces your suggestion the routine should offer an option to use MWF when appropriate. I haven't coded that part yet.

Regards

Joe Burke

  • Guest
Peter,

I will post a beta version of SF which incorporates your WMF suggestion in the original "Show your stuff" SF topic soon.

Please do not reply to this topic in the future. Direct all comments to the orginal SF topic in "Show your stuff" so we don't have versions/comments related to the routine posted in two different forums.

Joe Burke

  • Guest
Hi Peter,

I will post a new beta version of SuperFlatten to the original SF topic in Show Your Stuff soon. It uses a new sub-function named WMFOutIn to process objects like 3DSolids and some similar object types which cannot be flattened using other methods.

It does not use ExpressTools functions. The WMFOutIn function replaces ET calls in the example code you posted.

Thanks for your help with this. I think the routine is better with these changes.

BTW, the routine is not changed in terms of what it was originally designed to do.

Regards
« Last Edit: February 25, 2011, 08:32:50 AM by Joe Burke »

Joe Burke

  • Guest
Hi Joe,
I'm glad to see you again in this topic.

I will check my program later with the "3D House.dwg" ...
I am using ACAD 2009.
(I have to work with other things this time)

so long!
Peter

-----------------------------------------------------------
EDIT 28.01.11 (My last notice at this place as you suggested)
Have checked my SF version (with WMFOutIn) on ACAD2009:

Number of objects in model space before: 266 after: 10875
Number of objects not processed or flattened: 7
Object types not flattened: Light

Then saved as new drawing (as acad 2007 type drawing) and opened with recover (16900 objects + 8 blocks) without any errors.

in conclusion: successful flattening but worked very long (about 20 minutes in my virtual machine)

will wait for your new optimized SF version...

Peter,

I'll look at this and let you know what I find.

In the mean time, try the SF beta version I posted in Show Your Stuff today and let me know how it behaves. It should be more reilable than use of ExpressTools code.

Check the new WMFOutIn sub-function near the top of the code. It does all the WMF work.

Thanks
« Last Edit: February 25, 2011, 09:23:53 AM by Joe Burke »

peterba

  • Guest
Joe,
glad to see your new program version, but today I collect my stuff for winter holidays and will try your program later after 3 weeks.  :oops:
Peter.

chlh_jd

  • Guest
Hi ,
What about flatten by this way !
Code: [Select]
(defun C:3d2d (/ laylst d lay ss)
  ;;by GSLS(SS)
  (vl-load-com)
  ;;error handing
  (defun ss-errexit (msg)
    (command)
    (command)
    (if (or (= msg "Function cancelled")
    (= msg "quit / exit abort")
)
      (princ msg)
      (princ (strcat "\n错误: " msg))
    )
    (clos)
  )
  (svos)
  (vl-catch-all-apply
    'vl-cmdf
    (list "UCS" "N" "V" "" "LAYOUT" "N" "Test" "")
  )
  (setvar "CTAB" "Test")
  (setq ss (ssget "x"))
  (vl-catch-all-apply
    'vl-cmdf
    (list "ERASE" ss "" "MVIEW" "F" "" "MSPACE" "")
  )
  (setq ss (ssget "x"))
  (if (not SolProf_bak)
    (progn
      (setq SolProf_bak T)
      (vl-catch-all-apply
'vl-cmdf
(list "SolProf" ss "" "Y" "Y" "N")
      )
    )
    (SolProf ss "" "Y" "Y" "N")
  )
  (while (setq d (tblnext "LAYER" (null d)))
    (setq laylst (cons (cdr (assoc 2 d)) laylst))
  )
  (setq lay (last (vl-remove-if-not
    (function (lambda (x)
(wcmatch x "PV*")
      )
    )
    laylst
  )
    )
  )
  (setvar "CTAB" "Model")
  (vl-cmdf "UCS" "N" "V" "")
  (setq ss (ssget "x" (list (cons 8 lay))))
  (vl-file-delete "C:\\TEST.DWG")
  (vl-cmdf "wblock" "c:\\TEST.dwg" "" '(0 0 0) ss "");_here , you can change into another acad saving method .
  (foreach a laylst
    (if (wcmatch a "P[VH]-*")
      (vl-cmdf "ERASE" (ssget "X" (list (cons 8 a))) "")
    )
  )
  (vl-catch-all-apply
    'vl-cmdf
    (list "layout" "D" "TEST" "" "UCS" "W" "")
  )
  (vl-Catch-All-Apply
    '(lambda ()
       (vla-Remove
(vla-GetExtensionDictionary
   (vla-Get-Layers
     (vla-Get-ActiveDocument
       (vlax-Get-Acad-Object)
     )
   )
)
"ACAD_LAYERFILTERS"
       )
     )
  )
  (command "_.PURGE" "a" "*" "N")
  (clos)
  (princ)
)
(princ "/n高山流水3D实体Hidden线框转2D线框程序,命令3D2D")
(princ)
;;;---------------------------------------------------------------------;;;
;; save old sysvar
(defun svos ()
  (setq #system#    '("OSMODE"      "ORTHOMODE"    "CLAYER"
      "CECOLOR"      "PLINEWID"     "CELTYPE"
      "CMDECHO"      "ELEVATION"    "PICKSTYLE"
     )
#vlale#     (mapcar 'getvar #system#)
gsls_olderr *error*
*error*     ss-errexit
  )
  (vla-startundomark
    (vla-get-activedocument (vlax-get-acad-object))
  )
)
;; call old sysvar
(defun clos ()
  (vla-EndUndoMark
    (vla-get-ActiveDocument (vlax-get-acad-object))
  )
  (MapCar 'setvar #system# #vlale#)
  (setq *error* gsls_olderr)
)



Joe Burke

  • Guest
Joe,
glad to see your new program version, but today I collect my stuff for winter holidays and will try your program later after 3 weeks.  :oops:
Peter.

Peter,

I look forward to your comments when you have time to test the new SF 2.0a beta version.

I hope you'll find it's faster and more reliable than using ExpressTools functions.

I decided not to offer an option at the command line to use explode on 3DSolid and similar object types. WMFOutIn is used, assuming ACAD 2005 or later.

BTW, the code which deals object types other than things like 3DSolids and similar is not changed. So users of previous SF versions should get the same results with the new code.

Regards
« Last Edit: February 27, 2011, 06:27:51 AM by Joe Burke »

Joe Burke

  • Guest
Hi ,
What about flatten by this way !


I'm not sure what this code is designed to do. Maybe provide an example file?

chlh_jd

  • Guest
Hi Joe,
It just get 3dsolid hidden frame .

Joe Burke

  • Guest
Hi Joe,
It just get 3dsolid hidden frame .

I'm not familiar with a 3DSolid hidden frame. Is it something I should consider within the latest SuperFlatten code which deals with the 3DSolid object type?