DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Super-regen macro

Started by samdavo, March 25, 2013, 02:40:14 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DrollTroll

Not sure. I'm not getting that result. Once it's done, nothing is selected on my system.
Could be one of your option settings, maybe, like Group Objects When Created, or Select Objects When Created, or even Enable Offscreen Bitmap.
To be sure, however, you can try setting Sys(80) = 0 at the end, followed by a Regen statement.
25 years with DesignCAD

samdavo

#16
DT -  Easter, holiday, and I thought I'd try to get across this minor problem of why that macro apparently finished with everything selected. (and my perseverence has been rewarded - as much as an academic exercise as anything).

Just adding this post as an example of what NOT to do in macros, lol; 
DT, As for your suggestion, I'd already tried setting Sys(80)=0, and it hadn't worked (?) everything was still selected.  Finally twigged what was going on, by amending the macro to shift everything to the right by 20 units (and turning off the final fit to window).

Also I should explain that I recorded that macro rather than wrote it (the lazy man's way - or it could be argued, a quick way to get a first draft of a macro). I obviously set a superfluous point and thought it wouldn't matter. Turns out it caused the macro to pause (but it still finishes later).

I post three versions of my macro, one similar to what I first posted,
a second amended to help diagnose the cause,
and the third corrected.  It is clear that the "all selected" effect after the first is just a pause in the macro, and when you press "esc" to unselect, the macro runs to the end (and in the case of macro #2 it shifts everything to the right).

So I was 100% wrong when I said it indicates it had run to fruition.

Like the accident-prone scout leader, just trying to show you what knot to do. :(

FIRST VERSION (with error in red, and likewise flawed assumption) :-

'macro super-regen1, INCL ERROR, selects all, duplicates it, and deletes the orig.
'it sorts out some weird effects incl some zero segments
[color=red]'it ends with everything selected, but just press esc to sort that out. [/color]
for j = 0 to 255
layer(j) = 6
next j
layer(sys(3))=14
sys(26)=0
>SelectAll
{
  }
[color=red]>SetStartPoint
{
  }[/color]
>SetHandle
{
  <PointXYZ 0.000,0.000,0.000
  <PointXYZ 0.000,0.000,0.000
  <Type 0
  }
>SelectDuplicate
{
  <PointXYZ 0.000,0.000,0.000
  <Type 1
  <Reference 0
  }
>SelectDelete
{
  }
>FitToWindow
{
  }

SECOND VERSION (with changes in orange to investigate what was going on) :-
'macro super-regen2 is investigative only
[color=orange]'it PAUSES with everything selected, and when you press esc it completes the last few critical steps and shifts everything to the right [/color]
for j = 0 to 255
layer(j) = 6
next j
layer(sys(3))=14
sys(26)=0
>SelectAll
{
  }
[color=orange]'     >SetStartPoint (turned off)
{
  }[/color]
>SetHandle
{
  <PointXYZ 0.000,0.000,0.000
  <PointXYZ 0.000,0.000,0.000
  <Type 0
  }
>SelectDuplicate
{
[color=orange]  <PointXYZ 20.000[/color],0.000,0.000
  <Type 1
  <Reference 0
  }
>SelectDelete
{
  }
[color=orange]'        >FitToWindow (turned off, so as to leave everything shifted to right
{
  }[/color]

THIRD VERSION (with changes in blue is what I should have had in the first place, and doesn't end with anything selected ) :-

'macro super-regen3 - corrected
[color=blue] 'it ENDS with everything UNselected, and the option of FitToWindow [/color]
for j = 0 to 255
layer(j) = 6
next j
layer(sys(3))=14
sys(26)=0
>SelectAll
{
  }
[color=blue]'.......deleted[/color]
>SetHandle
{
  <PointXYZ 0.000,0.000,0.000
  <PointXYZ 0.000,0.000,0.000
  <Type 0
  }
>SelectDuplicate
{
<PointXYZ 0.000,0.000,0.000
  <Type 1
  <Reference 0
  }
>SelectDelete
{
  }
[color=blue]>FitToWindow
{
  }[/color]

In the unlikely event that anyone is sufficiently interested, can I suggest:-
a) loading the drawing (which this time has two lines in layers 1(black) and 2(red) resp, one or both of which toggle on and off, and one or both of which doesn't print)
b) running macro 1
c) then 2 = shift to right
d) then 3 = centred
(2 cents)

PS It also illustrates the "resilience" of macros, that they sometimes finish eventually, even if you screw up, and what you think is finished is really a pause.
PPS Turns out I can add "code" are an subsequent edit.

magic

Hi Sam,

When you post macros, please post them in a Insert Code window, it makes it easier to handle.
It's a kind of magic!




samdavo

#18
DT,
sorry to have to say this, but
there is still a problem (or more than one) with DeleteTinySegments...
(and I'll say up front that Super-regen doesn't help one iota with this one, because it involves tiny segments, not zero segments) ...

1. Just as with my (first) macro, yours can end with everything selected.   But that is easily sorted by pressing "Fit To Window".
2. However, there is a bigger problem, namely that only one problem is fixed with each running of the DTS macro.

Example:-
a. I enclose a (brand new) drawing 1c RYG-00.dcd which I drew from first principles. 

b.  I drew the green line (layer 4) as follows:-
0.00                0.00               0.00
0.00               50.00               0.00
-0.0000001     50.00               0.00  (i.e. a tiny segment <0.000001)
-100.00           50.00               0.00
When you select the line and check the Infobox, you find it (correctly) has 4 points.

c. I set it to have a width of 0.4

d. Yet (first strange effect - albeit minor), when I interrogate that line with DT's MakeNewXYZ macro, I find the following string data :-   
0.0000000000                0.0000000000               0.0000000000
0.0000000000               50.0000001000              0.0000000000
-0.0000001000              50.0000001000              0.0000000000
-100.0000000000           50.0000000000              0.0000000000
This is marginally different to what I used to draw the line, but we move on.
. Sorry that was my bad (see reply #22).  As I say, we move on.

e. It doesn't have the "toggle-on, toggle-off" problem,  BUT it does have the problem of not printing. i.e. When you print, eg to pdf, you find no lines appear (second strange effect).

f.  I copied-and-pasted the second and third lines using Ctrl+C and Ctrl+V resp; and changed them to layer 3(yellow) and 2(red) resp.  Reason being that you need more than one problem-line to demonstrate the error in the macro.   All three lines have 4 points when checked with InfoBox. (and hence a tiny segment).

g. I ran the DeleteTinySegments macro. 

h. It finishes with everything selected (third strange effect).  Easily sorted by pressing "FitToWindow", FTW.  (This is similar to what I found with my first macro, but presumably for different reasons)

i.  After pressing FTW, one finds that one of the lines now has 3 points, - and prints -  but two remain with 4 points  - and do not print -(fourth strange effect). 

j. If you run the macro three times, it progressively changes all three lines.

k.  After running the macro the third time, highlighting the green line, and running NewMakeXYZ, one finds (predictably) that the third point is deleted :- 
String data: 
0.00           0.00             0.00
0.00           50.0000001   0.00
-100.00       50.00           0.00

I enclose
1) the orig drwg, plus
2) the pdf when you print without running the macro (blank)
3) after running the macro once (1 x macro),  and
4) after running the macro three times (3 x macro).

samdavo

#19
Magic
Sorry for any confusion
Sure I can use "insert code" next time.  Not sure it will permit me to use colours though (?)
happy easter
sam

PS I believe I've been able to correct that "after the fact" - obviously by inserting {code] and {/code] as required, - except square brackets , cheers.

DrollTroll

Thanks sam, turned off Sys(36) and found an error that I had missed due to sloppy coding. DTS should work now. I hope!
25 years with DesignCAD

Dempsey

Sam,

What Magic means is that you should use "code" when including macro code. Shows a nice indented window in the reply with a scroll bar if needed.

Instead if PDF files it is friendlier to attached a JPG file. The forum system will show a thumbnail picture and when you click on the thumbnail it shows the enlarge JPG image; quick and easy to use.

PS -- images can be made in DCad: File --> Image --> Save Image File. Or you can use Windows 7's Snipping Tool; since I learned about this tool I use it most of the time.
Dempsey

samdavo

#22
DT
Checked your latest macro - that's one hell of a macro there.
If you try it on my drwg enclosed (also latest version), you'll find
a) it finishes without everything selected, - i.e. goes through to the "Fixed" message - (all good so far), and
b) it sorts out multiple or rather ALL the problems (ditto), ...

but, lol, PROVIDED you start it with all layers unlocked.

The drawing now has three lines, called entity 1, 2, and 3, and they are in layers 1, 2, and 3.

Going into the macro, I intentionally locked all layers except one (and it doesn't seem to matter which - can even be layer 15 that you unlock;
a) again everything was selected when the macro stops (prematurely?), and
b) it seems to fix either entity 3, or sometimes...
both entities 3 and 2 (rare - and I forget how I did it),
but it stops short of fixing the third, namely entity #1
c) when you run it again, and if necessary a third time (usually the case), each time locking all but layer 6 before doing so, you progressively fix them all, in the sequence entity 3, entity2, and entity 1.

PS I screwed up with my first alleged stange effect, para d.  The only strange effect is that my memory's not as good as it was.  Still, to be fair to me, lol,  it requires perseverence to get lines to misbehave in the first place - and I was trying to simulate the problem, as well as the solution.  Cheers.
I enclose another copy of that drawing, with para d. corrected., and as I say entities 1, 2, and 3 clarified and named.  Also I enclose the XYZ interrogation:-
Cheers, and enjoy your Easter, lol.

PS You know where fish get their Easter eggs from? - the Oyster bunny.
; XYZ data file produced by MakeXYZ.d3m
; Data for  3.000  objects.
; Grid lines and grid headers are part of the same grid object
; even though they have unique entity numbers.

; Entity 1 is type Line , on layer 1 .
; RGB color is: 255, 255, 255
; Line Type: 0 ; Line Width: 0.400000 ; ; Line Type Scale: 2.000000 .
; Group # 0 ; Solid # 0 ; Points: 4
; Selection Status: 3
; String data: 
0.0000000000 0.0000000000 0.0000000000
0.0000000000 50.0000000000 0.0000000000
-0.0000001000 50.0000000000 0.0000000000
-100.0000000000 50.0000000000 0.0000000000

; Entity 2 is type Line , on layer 2 .
; RGB color is: 255, 0, 0
; Line Type: 0 ; Line Width: 0.400000 ; ; Line Type Scale: 2.000000 .
; Group # 0 ; Solid # 0 ; Points: 4
; Selection Status: 3
; String data: 
0.0000000000 60.0000000000 0.0000000000
0.0000000000 110.0000000000 0.0000000000
-0.0000001000 110.0000000000 0.0000000000
-100.0000000000 110.0000000000 0.0000000000

; Entity 3 is type Line , on layer 3 .
; RGB color is: 255, 255, 0
; Line Type: 0 ; Line Width: 0.400000 ; ; Line Type Scale: 2.000000 .
; Group # 0 ; Solid # 0 ; Points: 4
; Selection Status: 1
; String data: 
0.0000000000 120.0000000000 0.0000000000
0.0000000000 170.0000000000 0.0000000000
-0.0000001000 170.0000000000 0.0000000000
-100.0000000000 170.0000000000 0.0000000000



samdavo

#23
thanks Dempsey, lol - I (just then) used the Insert Code option.  I'll get there.
Gents and/or ladies (but seems to be mainly gents) ...

Meanwhile ... and this introduces the question of the decimal points available in the info bar ...

I enclose a partial screen dump of the drawing prior to running any macros - shows the three lines, labelled.  Also the INfoBox, showing 4 points for the selected entity (entity#1). 

There are (arguably) not enough decimal points in the display of the x co-ordinate of the third point - not enough to fully interrogate it - and if you look carefully, point 3 is currently being interrogatred in that Infobox  ; 

(PS It shows the coords for point 3 as x = 0, y = 50, and z = 0;  where in fact, x = -0.0000001, but we move on...  the main "point" is that those numbers are edible :) )

- i.e. it is possible to truncate decimal places by typeing a zero or two
eg x = 0 , with possible tiny decimals, can be changed to x = 0.00
or indeed to add decimal places, eg x=0 can be changed to x= -0.0000001.

Yet another way to get rid of tiny segments or similar unwanted effects?
Food for thought ?  Probably nothing you didn't know already, cheers

samdavo

Just reinforcing/repeating the last post,

looking again at that jpeg/png whatever...   
1. If you change the coord for entity #1, point 3 from 
x = 0   to   x = 0.00
(this will overwrite the ACTUAL current value of x =  -0.0000001)

2. ... and then you will find when you print the drawing, entity 1 at least will print. (2 cents), although the others do not.

3. If you are interested, the line#1 has 4 points at this stage, 2 of which are identical.   If you run usper-regen (just out of interest ok?) you find it is tidied up to 3 points.   But no real change - it still prints as it did before, (and the other entities still do not.... UNTIL you run DT's DeleteTinySegments)

I remind you that this is more than just about the tiny segments, it seems to be also about wide lines ( as DT pointed out about 150 posts ago), and all these lines are 0.4 wide, a width I chose based on the scale of the original zigzag line that j-wetzel posted on "weird printing effects" thread.

samdavo

#25
And again, just to illustrate the technique of forcing corrections to coordinates using the InfoBox...

I enclose another copy of J-wetzel's problem drawing "1b.dcd" (with a small bend between g and m to highlight an irrelevant distraction there).
- both original and corrected.
How did I correct it?

I simply
1. clicked "fit to window" until the line appeared,
2. opened info with it selected
3. noted that points 5 and 6 were more or less identical, at least the "coordinate cells" show them to 4 decimal places,  i.e. x= 69.4918********,  and y = 5.5676******** in each case.
4.  the problem, presumably is that the ******** in one case is not quite the same as the ******** in the other.
5. now for the correction,  simply copy the number in the x-cell that applies to point 5, and paste it into the same box for point 6;  and likewise the y value.
6. click outside the InfoBox to accept the new values
7. you will find that the line still has 13 points, (including 2 points at "e"), but  the zigzag line no longer toggles, and also, the line prints no probs.   

I call the png file "1b corrected by InfoBox", 2 cents

samdavo

#26
Sorry, as I keep teaching myself things, I write them down -
IN summary, you can manipulate x and y (and z) coords in the InfoBox as follows:-

1. you can copy and paste coordinates between cells,
2. you can add decimal places either by changing "69.4918****" to 69.4918001
3. or by putting a calculation "69.4918+0.000001"  (but beware, this will loose the **** decimal places above)
4. you can truncate/limit decimate places at the current 4 places by adding a space where the 5th decimal would be.
5. you can obviously force the coordinate to fewer than 4 dec places if you wish, by simply deleting some.

As an example of option 4 above,
I enclose the XYZ interrogation of the zigzag line in "1b bent.dcd"  both before and after that process applied to each and every x and y point along that line. 

Firstly before ...
; XYZ data file produced by MakeXYZ.d3m
; Data for  1.000  objects.
; Grid lines and grid headers are part of the same grid object
; even though they have unique entity numbers.

; Entity 22 is type Line , on layer 1 .
; RGB color is: 0, 0, 0
; Line Type: 0 ; Line Width: 0.400000 ; ; Line Type Scale: 2.000000 .
; Group # 0 ; Solid # 0 ; Points: 13
; Selection Status: 1
; String data: 
71.6901584808 -21.8629543960 0.0000000000
58.4706966864 -17.8971184190 0.0000000000
53.8947291421 -12.1008927087 0.0000000000
58.1656321834 1.0168812672 0.0000000000

69.4918139156 5.5676441463 0.0000000000

69.4918139156 5.5676441463 0.0000000000
81.1471580722 -20.8460726924 0.0000000000
78.6258785485 5.7198785551 0.0000000000
87.1785977509 -4.7995769173 0.0000000000
93.1463618548 -17.2869893969 0.0000000000
98.3324584050 0.1016877340 0.0000000000
97.4281188291 -14.2079730638 0.0000000000
102.1966087756 -10.7789464941 0.0000000000

Secondly after adding a space in the 5th decimal place position in all x and y cells :-
Note that the second set has only 4 dec places in each case :-
; ; XYZ data file produced by MakeXYZ.d3m
; Data for  1.000  objects.
; Grid lines and grid headers are part of the same grid object
; even though they have unique entity numbers.

; Entity 22 is type Line , on layer 1 .
; RGB color is: 0, 0, 0
; Line Type: 0 ; Line Width: 0.400000 ; ; Line Type Scale: 2.000000 .
; Group # 0 ; Solid # 0 ; Points: 13
; Selection Status: 1
; String data: 
71.6902000000 -21.8630000000 0.0000000000
58.4707000000 -17.8971000000 0.0000000000
53.8947000000 -12.1009000000 0.0000000000
58.1656000000 1.0169000000 0.0000000000

69.4918000000 5.5676000000 0.0000000000

69.4918000000 5.5676000000 0.0000000000
81.1472000000 -20.8461000000 0.0000000000
78.6259000000 5.7199000000 0.0000000000
87.1786000000 -4.7996000000 0.0000000000
93.1464000000 -17.2870000000 0.0000000000
98.3325000000 0.1017000000 0.0000000000
97.4281000000 -14.2080000000 0.0000000000
102.1966000000 -10.7789000000 0.0000000000


Finally, (at risk of boring you), I enclose the view of the InfoBox as you add that "space" after each number - you will note the cursor in the x cell confirms I have added a space.  And this is all you need to do to get rid of unwanted decimal points, and convert
69.4918139156, 5.5676441463
to
69.4918000000, 5.5676000000

And as I say above, that is enough to stabilise the drawing, both on the screen, and for printing.
PS I agree- this one has probably been flogged enough.
Quote for the day,   18th century human resources manager addressing the crew ..."the floggings will continue until morale improves!"

samdavo

#27
One final matter
I believe this version of DeleteTinySegments works, whether or not you unlock all layers first -  (as you seem to have to do with DT's latest version)...
because it does that in the first instance - the rest of the macro is unchanged, and, I have to admit, only half understood- by me anyway.
cheers
sam


PS The additional lines are as follows  (but there are bound to be better ways);  I have to seriously brush up my macro skills!  Learn how to write one like DT or Paul - and Paul, thanks again for that macro posted above.


'open all layers
for j = 0 to 255
layer(j) = 6
next j
layer(sys(3))=14
sys(26)=0


Note that I only open 255 layers - I presume some may want to change that to 2000 or however many layers you have used.  Were it only used by me, I would only open 20 layers, which would always be adequate.

gotta feeling that the last two lines above are optional, but what the heck, done now.

PPS Could someone please post the full set of SYS() functions - or the best thread to "regenerate" macro-writing skills ?  I have to go back to macros I understood 20 years ago... whatever :)
Water, bridges, (time, erosion) etc 
Would be much appreciated.

Dempsey

#28
Sam,

http://forum.designcad.com/index.php?topic=5.0 is the lasted official documentation as per version 17.0.

There has obviously been tweaks to some of the parameters. Look for the essential ones in the release notes versions 18 to 22 at http://forum.designcad.com/index.php?board=17.0, or ask on this forum when you run into a problem.
Dempsey