DesignCAD User Forum

In dcad 2016 I use several macros that insert a new object at the cursor position or the position of a handle. Often when I use one of these it will insert the new object at a point far distant from where it should go. If I then close dcad and restart it, the macros will work properly. I would like to find a permanent fix for this problem. Can anyone help?

Here's one that reflects along the y axis, then resets the default to x axis so I can have separate hotkeys for the two axes and reduce mousework. It works fine after a restart, but later starts putting the reflection way off in the boonies.

Lar, I'll try that. It may take a while to know if it works, since the macros only start misbehaving after I've been working for a while. I made this macro and several others with the macro record tool, so the lines were generated automatically. Might I be doing something wrong when I record a macro? The opening square bracket is not in the code, dunno where it came from.

The SetStartPoint is your macro's origin. All your PointXYZ's set their points using your StartPoint as 0,0,0. So once you start the macro and click somewhere, that becomes 0,0,0 for that running of the macro. All your macro does is reflect your selection along the Y axis then along the X axis then undoes the 2nd mirror (but now your mirror command is set at X axis, as you said).

Hmmmmmm, the only other thing that I can think of is that you are thinking dcad uses the sticky handle when mirroring but it actually uses the selection handle, ie, not the handle with the zero in it but the big blue dot that appears where ever you click when click-selecting something. Or, if you dragselect it puts big blue at the center of the selection rectangle, or if you 'select all' big blue goes at the center of everything selected, or if 'select when created' is on then big blue goes to the default spot for the type of entity just created (eg, for a box it goes at the front-left, I think... for a circle it goes at the center point).

I can't remember what 'Type 1' for the mirror command means ('make a copy'?) ...it's best to put comments to explain things like that when seeking help for macros on the forum...

If this is the case and according to your code the selection is already made when you start the macro. So, before starting the macro make sure the big blue selection handle is where you need it to be. When you set a fresh set of handles big blue comes instead of handle-zero. Later on when you select this entity again and if you have 'sticky handles' on, handle-zero will be where big blue first was and big blue would now be in one of the locations I described above. Sticky handles only stick to single entities and single blocks, solids and groups. If you select more than one of these and you use the handles command they would not stick, they would only work while this stuff is selected (and if you 'select previous' to reselect this set of stuff after selecting something else). Each individual will retain their sticky handles.

I think I just figured it out. I'm not using sticky handles. Often when I sometimes reset the origin of the coordinate system so I can read the absolute coordinates of a point and know what it means. To use this macro I first select an object, giving it one handle, then activate the macro. Next I click somewhere and that point becomes the handle of the reflected object if I haven't set the origin since starting dcad. But if I have set the origin the reflected objects apears at some other place, usually far distant and off screen. Other macros which create new objects behave in the same way.However, figuring out what causes a problem is not quite the same as fixing the problem, and in that regard, I am at a loss. Here is a macro that does nothing but set points for a line. It creates a 2x4 in cross section with a point at the center. If I haven't set the origin since starting dcad, the first point I click after choosing the macro is a corner of the 2x4, but if the origin has been reset it appears in a different place. It seems like >SetStartPoint is not recognizing the change of origin. Is there a way to overcome this?

It seems like >SetStartPoint is not recognizing the change of origin. Is there a way to overcome this?

The purpose of >SetStartPoint is to ignore the origin of the drawing and become its own origin. When you start your macro and click that first point, that first point becomes the origin that the macro uses. Every >PointXYZ that the macro encounters is measured from that start point. The origin of the drawing is ignored. Far as I understand you can have as many setpoints in a macro as you want so each time you set one that becomes the origin that the macro uses until another setpoint is encountered. The origin of the drawing does not move but it is ignored while the macro runs.

To use this macro I first select an object, giving it one handle, then activate the macro. Next I click somewhere and that point becomes the handle of the reflected object I...

Once you start the macro the next click is the start point, not the mirror handle. The only reason the mirror sometimes work from there is because in the code the point is set at 0,0,0, which is the start point.

I think your problem stems from your misunderstanding of the start point. I myself only recently grasped that the start point becomes the origin that all >PointXYZ's are measured from. Whenever I recorded a macro the first thing I always did was delete the start point part if it was there. However, for my last recording I wanted to use start point so I left it in, not knowing that the pointxyz's would be measured from the start point. The macros was not working as expected so I had to go in and figure out why. Once I grasped the effect the start point was having I had to figure out another way to write the macro.

Ok, I get that the next click after starting the macro is the start point, so 0,0,0, in the macro is that point. But why would it matter that I had earlier reset the origin by use of the "point,origin" command? Before I have done this, the macro works, setting the new object at 0,0,0 relative to that "next click". After I have reset the origin, the new object is set at a distant point.

I vaguely recall an issue posted some time back where the origin of the drawing is cached when it is loaded, and resetting it does not clear this cache, and some operations still find the original setting.

Can you confirm that after closing and reloading the drawing with the reset origin, and/or after closing and reloading Designcad, the operation of your macro works correctly again, until you change the origin again during the current session?

Also, if you offset the origin by a specific distance, does the mirror copy appear at twice that distance away?

Rob, yes, the macro works correctly if the origin has not been set since opening dcad, i.e. it sets the new object at the first point clicked. In response to your second question, I reset the origin one unit above the initial 0,0 of the session and now the macro sets the new object one unit above the first point clicked (not 2 units). Are we on the way to a solution?

You will have to describe in detail every step you take, or upload a video for us to grasp what is going on.

Eg, how are you setting the origin while the macro is running? I know this can be done with your macro but I would like to hear how you do it. Actually it's more like I would like to know if you do it during the running of the macro or do you do it between macros. Reason I would like to know this is because, like I said above, the start point is only in effect during the running of the macro. Once the macro ends the drawing's origin regains control. So, if you are changing the origin outside of the macro then it has nothing to do with the macro. Even if you are changing the origin during the macro you can only do it before you set the start point so it will still have no effect on the running of the macro.

When you say you set the origin 1 unit higher than previous, do you then run the macro? If you do, the start point will still be where ever you click next. Also, if the mirror then happens 1 unit higher all it means is it is using the drawing's origin. You must have changed the origin, then start the macro and used the regular PointXYZ command to set the start point, thus it would be 1 unit higher than before you set the origin. If you had snapped to an existing point to set the start point, or used the regular Point Relative from an existing point then the mirror would happen in the exact same place.

Another thing I would like to know is are you recording the macro each time you need it or are you reusing the same macro all the time?

I'll try to explain it more clearly. Starting with a new file, I drew a horizontal line and a vertical line, intersecting at point 0,0, the drawing origin, and saved it as macrotest.dcd. Then, using macro record, I made a macro that sets a bullet pointmark at the first point clicked after starting the macro, and saved it as "bullet.d3m". That produced the file attached below.

Then I took these steps:1. start dcad2. open macrotest3.click the intersection of the lines to verify it's coordinates are (0,0). They are.4.activate bullet.d3m.5. click on a point of the horizontal line to the right of the intersection, producing one of the bullets in the attached screenshot. Just what the macro is supposed to do.6. repeat #5, just to be sure it still works.7.choose "point origin" 8. using "point relative", set the origin on the vertical line one unit above the intersection with the horizontal line.9.activate bullet.d3m10. click on the horizontal line to the left of the intersection. this produced a bullet point one unit above the horizontal line.11. repeat, with the same result.

I have done this many times with the same result, with this and other macros that insert a new object. the origin is never changed while the macro is running. the macro inserts the object at the first point clicked after it is activated only if the origin has not been set since dcad was started, and if the origin has been set, the new object is inserted a distance away from the first point clicked equal to the distance from the opening origin to the new origin.

I think I attached a screenshot as clipboard01.jpg to this post, but don't see how to verify that. Can the picture be made to appear with the text? Anyway, I hope this is an adequate explanation of the problem.

Yea, Rob. I followed Rccon's instructions in his last post and got his results. It seems like Rccon uncovered a bug, but since I hardly ever used >SetStartPoint I can't say if this is somehow the expected result, for those who do use setstartpoint.

What I have deduced is this: when you change the origin of the drawing not everything gets the memo, >SetStartPoint included. So, when you set the start point, it coordinates itself in relation to the original origin. Meanwhile, the commands did get the memo that the origin has changed so they carry out their instructions in relation to the new origin. Hence, the differential. I personally stopped changing my origin because when I export to Cinema 4D to render/animate, Cinema 4D always used the original origin, not the new one. So I guess the exporter don't get the memo either.

The good thing is Rccon's solution is quite simple. Just don't ever change the origin. In fact his problem was caused by him changing the origin. Changing the origin is totally unnecessary as long as >SetStartPoint is there at the beginning of the macro and the commands in the macro has the <pointxyz being set at 0,0,0. If he does have to change the origin for some other purpose, change it back to its original location before running the macro

So I guess the reason I've had this problem and others have not is that I'm the only one who commonly changes he origin, and maybe it's a bad habit that will need to change. Often I want to know the vertical & horizontal distances of several points from a certain point in a drawing. I can use the distance command, but it is quicker & easier to set the origin at my reference point, click once at each point in question and read the coordinate bar. I've found other uses, too. As a keyboard guy, I'm always trying to get out of mousework. Is there any chance programmers will address this issue?

I can use the distance command, but it is quicker & easier to set the origin at my reference point,

The distance command ("Angle & Distance between points", Dimensions menu>Info...) has lots of features, like showing the direct distance as well as the deltaX, deltaY and deltaZ, being able to change the tolerance, change the units and how the result are displayed. Give it a custom key so it's easy to invoke. I changed mine to "U", which is normally for the "Units" command, and I changed Units to Alt+U. <<thanks to DT for giving me that bit of advice some years back>>