Author Topic: UnFold, Flatten, Unroll, etc. for GRID entities  (Read 8120 times)

ablincoe

  • Newbie
  • *
  • Posts: 37
UnFold, Flatten, Unroll, etc. for GRID entities
« on: April 28, 2014, 05:02:07 PM »
I thought that there might be an interest here for for my latest macro.  Due to it's size (over 1000 lines), I have placed it here as an attachment instead of inclusion in-line.  Place the "UnFold.d3*" files in the directory where you normally store your MACRO's.  Due to the number of parameters that control this function, I copy the "UnFold.d3i" file out next to your drawing file (Drawing_Name_UnFold.d3i) so that you can tell what parameters were last used when unfolding this/these objects.  Editing of the parameters is done with NotePad, so be careful on how you modify the parameters.

Allen

P.S.:  I guess that if you don't succeed at first, then  Try, Try, again  is the appropriate method....
     DesignCAD_UnFold.doc  -  A much fuller description of the macro and it's flow
     UnFold.d3m  -  The Macro
     Unfold.d3i  -  The basic parameter file to control the macro.
     I think I got it correct this time.
« Last Edit: April 29, 2014, 06:57:42 AM by ablincoe »

Dr PR

  • Hero Member
  • *****
  • Posts: 5378
Re: UnFold, Flatten, Unroll, etc. for GRID entities
« Reply #1 on: April 28, 2014, 11:54:35 PM »
I have experimented with this macro, and it does in seconds what it took me a day to do manually!

It works only with true grids, but it will unfold anything from cones to boat hulls!

Phil
DesignCAD user since 1987

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: UnFold, Flatten, Unroll, etc. for GRID entities
« Reply #2 on: April 29, 2014, 07:38:49 AM »
     I think I got it correct this time.

Holy cow Allen!  1367 lines of code.

« Last Edit: April 29, 2014, 07:46:35 AM by prl »

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: UnFold, Flatten, Unroll, etc. for GRID entities
« Reply #3 on: May 02, 2014, 02:25:37 AM »
Ablincoe   (or anyone)
I'm itching to give your macro a run - however, I've run into a really basic problem.

I subracted a solid from solid ( green pipe from red pipe).
and exploded the solid ( which gives planes).

How do I change that to a grid?

(edit - ahhh I'm guessing surface connect - more perseverence - to be continued)
« Last Edit: May 02, 2014, 02:44:17 AM by samdavo »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: UnFold, Flatten, Unroll, etc. for GRID entities
« Reply #4 on: May 02, 2014, 02:52:16 AM »
Sam, the short answer is you can't. DesignCAD grids with openings (solid add/subtract operations) always reduce themselves to facet assemblies.

The long answer is you could possibly do it manually, setting all the points, etc. around the opening and stretching/fitting a grid.  The Doc would know more about this.  His shipshape models need grids to maintain reasonable drawing size(s), so I'm sure he has few tricks up his rolled up sleeve.

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: UnFold, Flatten, Unroll, etc. for GRID entities
« Reply #5 on: May 02, 2014, 03:32:45 AM »
prl
Yep - I've done it manually with surface connect.
But still no joy with the unfold (as yet).
« Last Edit: May 02, 2014, 03:36:53 AM by samdavo »

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: UnFold, Flatten, Unroll, etc. for GRID entities
« Reply #6 on: May 02, 2014, 03:42:33 AM »
ok ! eureka!
it works! lol.

I see slight resemblance to the grid I drew,  but it looks pretty impressive.
Thanks ablincoe. :)

PS I suspect my grid had a few bugs - not uncommon for surface connect done in a hurry - in my experience - cheers
« Last Edit: May 02, 2014, 04:02:39 AM by samdavo »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: UnFold, Flatten, Unroll, etc. for GRID entities
« Reply #7 on: May 02, 2014, 03:50:01 AM »
I see little relationship (ok slight resemblance) to the grid I drew,  but it looks pretty impressive.

Sam, can you sew it back together to verify?  (I know, I'm a troublemaker).  :)

Thanks for the model files.  Gives me something to look at.

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: UnFold, Flatten, Unroll, etc. for GRID entities
« Reply #8 on: May 02, 2014, 05:28:37 AM »
Sorry prl,
Here's a more careful "surface connect".

During the running of the macro, it "crashed" with a message to say that there was a tolerance problem.
However it had already drawn much of the convex part of the surface (and there are no longer any crossed fingers, nor any doubling back on itself which you get with a concave surface ( see previous post).

Anyway - a better grid to try out - over to you.
cheers.
« Last Edit: May 02, 2014, 05:31:21 AM by samdavo »

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: UnFold, Flatten, Unroll, etc. for GRID entities
« Reply #9 on: May 02, 2014, 02:49:18 PM »
I suspect my error was to include construction lines with the grid before running the unfold macro.  Certainly (on this occasion) you avoid the message if you only choose the grid.   But my grid still needs more care I suspect.    (2 cents) 

ablincoe

  • Newbie
  • *
  • Posts: 37
Re: UnFold, Flatten, Unroll, etc. for GRID entities
« Reply #10 on: May 02, 2014, 05:42:47 PM »
Sam, PRL,
Tolerance errors come from 2 possible areas.
     1)  If the sum of the angles within a grid Rectangle/Triangle do not add up to  360/180 (ish), an exception is issued
     2)  After building the "next points" on the calculated line, if the two new ends do not have a distance that is equal to what is expected by the grid definition (ish), an exception is issued.
     Either area can become an issue if there is a DC Math Enumeration issue, a bug within the code, or possibly someone altering a grid manually.

I am not sure if the output you are getting is the most beneficial for your purposes.  I would refer to your output as a "Fish Bone" type unfold.  If you change the  "RET_LNPT" variable, the output may be more what you are looking for.

The inclusion of miscellaneous entities within your selection should not cause a significant issue as the macro is very careful about choosing only the "Grid" type entities to work with.

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: UnFold, Flatten, Unroll, etc. for GRID entities
« Reply #11 on: May 02, 2014, 09:38:54 PM »
ablincoe,
so I copied your macro so that I can run either "unwrap" (set to 1) or "unwrap with reversed LPR" (set to 2).  However I don't see any (significant) difference in the final result.

Rather than confuse this thread I will post another way to do this on another thread - using one of prl's macros - and also a bit of preparatory work.   It works on
a) unrolling vertical planes based
b) on the perimeter of a polygonal-horizontal-base-plane-shape.   
As such it avoids the need for a grid (which I am personally finding a bit - err - subjective).   But no doubt has shortcomings of its own (including a and b). 

Please refer to the "cutting holes in pipes" thread.
http://forum.designcadcommunity.com/index.php?topic=5464.52

Undoubtedly it will end up a case of horses for courses.
But if I may be so bold as to make a suggestion for YOUR macro, it would be easier if it worked on planes, or maybe a solid made up of a set of selected planes  (as that macro of prl's does).   Sorry if I am being disrespectful, especially as I wouldn't have a clue how to write either macro, yours or his.
« Last Edit: May 03, 2014, 12:00:27 AM by samdavo »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: UnFold, Flatten, Unroll, etc. for GRID entities
« Reply #12 on: May 03, 2014, 03:53:47 AM »
I am not sure if the output you are getting is the most beneficial for your purposes.  I would refer to your output as a "Fish Bone" type unfold.  If you change the  "RET_LNPT" variable, the output may be more what you are looking for.

Allen, your work is so advanced and powerful that I hardly comprehend all that it can do and offers!  Besides the general concept of unfolding things for simple items such as cylinders and maybe the occasional notched cube or such, visualizing the result of unfolding a complex surface is mind blowing.


ablincoe

  • Newbie
  • *
  • Posts: 37
Re: UnFold, Flatten, Unroll, etc. for GRID entities
« Reply #13 on: May 03, 2014, 07:01:48 AM »
Sam,
If the length and girth of your object are close in size, then there may be very little difference between the two options. 

The main reasons that I tackled the "Grid" objects were:
     1)  I could get my head wrapped around how DC created and utilized a grid
     2)  Each piece/section of a grid is "solidly connected" to it's neighbor (or you have an outer edge of the grid)

When you step into the "3D Object" world, then there are way too many things to consider (for me at least at this time).  When you look at the DC components of an object, a simple cylinder is composed of  2 36-sided Planes (the Ends), and a grid that is 36x1.  Trying to automagically locate how/where the "Plane(s)" meet and connect to the "Grid" is not an easy task. 

If you simply subtract a second cylinder from the first, the object turns into a series of all planes (74 of them!).  They are the  36 inner cylinder sides, the top and bottom, and then the 36 outer sides. 

And yet another twist, is that a DC "Plane" does not fit the geometrical definition of a "Plane".  It is not necessarily a "Flat Plane", and thus, how to flatten it for this purpose.

Comments and suggestions are always welcome, and are not taken as a sign of disrespect or negativity.  I am not (and have never been) a CAD professional.  Most people would say that I use DC as a "Computer Aided Drafting" system with a 1960's (Primary School) view of Paper/Pencil based drafting.  Having the flexibility of DC is a VERY HUGE improvement to how/what my old(er) education along with paper and pencil could do for me.

It is quite possible that this tool is not powerful enough for the type of UnFolding that you need.  I'm not sure if my IT background can ever get this process to what can be done "visually" by the human operating this system, but this has provided a significant improvement to my "model building" and material planning processes for retirement.


Allen

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: UnFold, Flatten, Unroll, etc. for GRID entities
« Reply #14 on: May 03, 2014, 07:19:10 AM »
And yet another twist, is that a DC "Plane" does not fit the geometrical definition of a "Plane".  It is not necessarily a "Flat Plane", and thus, how to flatten it for this purpose.

Yes, DesignCAD planes are warpable.

I have observed the following general rules.

1. If a DesignCAD plane is warped, it consists of more than 4 points. Remember for DC planes, point 1 and point n are the same.  So for the most basic case, a triangular facet is four points (n = 4) and is by definition a proper mathematical plane (provided you're not tricking it, aka improper planes, another topic.)

2. If a DesignCAD plane is warped, DesignCAD will create a subset of pure mathematical planes (n-3).  So a warped rectangular DC plane (5 points, n = 5), will consists of 5-3=2 proper mathematical planes:

    facet 1:  points 1, 2, 3, 1
    facet 2   points  n-2, n-1, n, n-2


Note I say If.  DesignCAD planes with more than 4 points may be mathematical planes but not necessarily, so you have to test the points when n > 4.
« Last Edit: May 03, 2014, 08:42:31 AM by prl »