Macros

Description of your first forum.

Macros

PostPosted by Bjorn Holmgren » Mon Aug 18, 2014 6:02 am

Sorry, trying to learn how to get a video demo running here ...

Mike Benton got me to write a Legal Description macro.
This is what it does at the moment ...
Legal description : http://www.screencast.com/users/BjornR/folders/swfs/media/b314fdfe-ad05-4683-9703-21a93a0e0d09...

Bjorn :geek:
Bjorn Holmgren
 
Posts: 50
Joined: Fri Jun 06, 2014 11:04 am
Location: Sunshine Coast QLD Australia

Re: Macros

PostPosted by CET » Tue Aug 19, 2014 9:19 pm

Very nice job Bjorn! Sorry I've been AWOL on this.

CT
CET
 
Posts: 39
Joined: Mon May 26, 2014 10:55 am

Re: Macros

PostPosted by Matt » Thu Aug 21, 2014 10:44 am

Nice job Bjorn! You are a macro magician.
Matt
Site Admin
 
Posts: 149
Joined: Mon Apr 21, 2014 2:31 pm
Location: Spokane, WA

Re: Macros

PostPosted by Dondy2 » Fri Aug 29, 2014 8:33 pm

FANTASTIC,....!
Dondy2
 
Posts: 13
Joined: Sun Jun 08, 2014 10:59 pm
Location: Edmonton, Alberta Canada

Re: Macros

PostPosted by PHINESLS » Sun Apr 03, 2016 9:06 am

Bjorn,

How can I get your "Write a Legal Description macro" loaded on to my Computer. This is a very Heavy Duty Macro.

Regards,

Rusty
PHINESLS
 
Posts: 81
Joined: Sat Jun 21, 2014 6:13 pm
Location: Amagansett, New York

Re: Macros

PostPosted by Ficx » Sat May 07, 2016 1:55 pm

I assume that this is the appropriate place to post the following, since it's related to macros.

Using /GET,LineColor in a macro yields $VAL:1694156.0 for any active line color. Have to resort to /EEX, instead, to extract line color info. One would expect the following values when using the /GET,LineColor command:

10 - green
12 - red
14 - yellow, etc.

Running Windows 10 Home ed, GCP 12.1.27 in demo mode.
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Bjorn Holmgren » Sun May 08, 2016 3:42 am

/SET,LINECOLOR,~; is also defective.
/GET gets me $VAL=1629292, wonder what these values mean?

The old Generic Cadd extractions work still.
LC,!,/VIN,1,$VAL; will extract and store current LC setting in $I(1).
Bjorn Holmgren
 
Posts: 50
Joined: Fri Jun 06, 2014 11:04 am
Location: Sunshine Coast QLD Australia

Re: Macros

PostPosted by Ficx » Mon May 09, 2016 12:36 am

I didn't know about this old Generic Cadd extraction command. Thanks for pointing it out, Bjorn.
This issue will most likely be addressed and rectified.

I wanted to start a new new topic, but it seems that I either don't have permission to do so in this forum or I'm blind and can't find the way to do it. I'm going to post it here. Please move it to another section if you deem that it belongs elsewhere. The topic header was gong to be "Where do we go from here?"

From the GCP website I get the impression that things are moving along at a very slow pace -- one could even say that things are suspiciously stagnant. Are there any plans at all for a version 13?
Is there a remote chance of adding a couple of extra features? Can one make a last ditch argument for lines and arcs with arrowheads? I wrote macros for these and they work more-or-less to my satisfaction, but nothing beats having these features as integral parts of the program with all the nuances built in.
I suggested this many years ago and received a negative response; I'm going to give it another shot in the hope of positive one. There are many people who would benefit from having these features added to this great drafting software.
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Dave Calvert » Mon May 09, 2016 5:37 pm

Ficx,
I'm not sure if this is what you are looking for but the AD command does what I think you are looking for. I think it has been in the program for the last couple of versions.
Dave
Dave Calvert
 
Posts: 11
Joined: Tue May 27, 2014 6:09 am

Re: Macros

PostPosted by Ficx » Mon May 09, 2016 7:18 pm

Dave,

I'm thinking in the context of physics, not entity dimensions. For clarification, this is what my marcros do:

I. Vector:
Enter two-letter command VV, click a point for tail, click a point for head. Done.

II. Arc-vector:
Enter two-letter command AV, select vertex, click first point, click second point. Done.

Both work in the sense of from here to there; that is, the first point is the tail, the second is the head. VV is similar to L1 and AV is similar to A2.

Ficx
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Bjorn Holmgren » Tue May 10, 2016 4:03 am

Using a macro the leader points can be reversed to tail-arrow order.
Settings and Resets may be varied to suit a user.

;*** ARROWLINE Bjorn Holmgren 2016
.SETTINGS;
DD,T,--,; Dim Text Off
US,R,S,0,A,T,O,,,; Shoulder Length = 0 Arrow = Open
.ARROWLINE;
/VPT,1,@,L1,LP,@,OO; Tail to Arrow points
LE,,LP,$X(1),$Y(1),; Leader with reversed points
.RESET;
DD,T,++,; Dim Text On
US,R,S,500,A,T,S,,,; Shoulder Length = 500 Arrow = Slash
Bjorn Holmgren
 
Posts: 50
Joined: Fri Jun 06, 2014 11:04 am
Location: Sunshine Coast QLD Australia

Re: Macros

PostPosted by Ficx » Tue May 10, 2016 11:59 am

Bjorn,

Your macro skills are exceptional. My macro is several times longer than yours. But mine does have some features that are absent in yours. For example, mine makes use of the active line color and works regardless of the current entry mode (ABS, BAS, REL). Yours gives curious outcomes when REL is active -- things that can easily be fixed by adding a few extra lines of code.

Regardless, my point is that I would like to have full control of lines with arrowheads (vectors) and there are limits to what macros can do. Drawing a vector with rubberband ON, showing the arrowhead, would be nice to see; I don't know how to get a macro to do this. Someone with vast macro programming knowledge like you can get very far. But the average Joe, like myself, hits a wall much sooner. That's why I think that vectors (and arcs with arrowheads) should be added to GCP's built-in repertoire. The user should be able to efficiently work through a drawing that includes vectors and have quick and full control regarding color, width, arrowhead type and angle, filling, etc.

Ficx
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Tom Albright » Tue May 10, 2016 8:18 pm

Here's a macro that places an arrowhead on the end of an existing line or arc - It matches current text color and arrowhead is proportional to text size:

/XMD,++,/CHD,--,;
DQ,SA,TEMP,!;
LL,!,/VRL,4,$VAL,LL,0,;
SG,??,/VIN,2,$VAL,;
TZ,!,/VRL,3,$VAL,;
US,R,A,T,F,A,15,L,$R(3)*.75,!,U,++,!,!;
UL,-1,;
OR,--,SG,--,;
TC,!,/VIN,1,$VAL,;
DQ,DP,R,C,$I(1),!;
/XMD,--,;
LE,!,@,SO,@,!,!;
OR,++,;
SG,++,/IF,$I(2)[EQ]0,SG,--,;
LL,$R(4),;
DQ,LO,TEMP,!;
/CHD,++;

I have a number of curved and straight leader macros, two of which occupy F1 & F2. None of my leader macros place text.
Tom Albright
Tom Albright
 
Posts: 92
Joined: Mon Jun 02, 2014 6:53 pm
Location: Billings, MT

Re: Macros

PostPosted by Ficx » Tue May 10, 2016 11:37 pm

Bjorn and Tom both seem to avoid using the /GET and /SET commands. Is it because your approach is easier or more logical in terms of the 2-letter structure of GCP or is it because there are some bugs that haven't been addressed? I found that /GET,ArrowType is also not working; ArrowType is not on the list of accessible variables, but it should be.

Tom, I like the arrowhead proportionally changing size to match textsize. The arrowhead is on the wrong side of the line, though. Several programs do it that way, but it seems very unnatural to me. Also, got an error when I ran your macro because the folder c:\General CADD 12\Cfg\Dims\ does not exist in my system. I added the folder and the macro does it's job with a sound(???) at the end. Finally, your macro leaves OR on.

Bjorn, I worked with your macro a bit more and I got a feel for it; that's how I found out that /GET,ArrowType doesn't work. But, I also noticed that you assumed some values, changed the settings and then reset them to the assumed values (Shoulder Length = 500 Arrow = Slash). What I like about your and Tom's approach compared to mine is that the vector is one entity; it can be erased in one shot.

Still, I prefer that vectors be on a par with commands such as L1; built into GCP so that the user doesn't have to be concerned about whether some setting was changed by a macro and then having to go and reset things manually to the way they were before the macro was used. A well-written macro must return everything it changes to the state they were in before and allow the user, if called for, to make some selections. But there are some selections that are reserved for the system and are not accessible by macros.

In the case of a macro that uses setups that exist for other entities, like dimensions and leaders, one may have to then go back and change those settings before dimensions and leaders are used again and on their own. In other words, there may be a conflict in settings for the intended use of the macro and, say, the independent dimensions and leaders settings. That's why I believe that vectors should be built into GCP and have their own, independent settings.

Ficx
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Tom Albright » Wed May 11, 2016 1:22 pm

Ficx,

What do you mean by, " The arrowhead is on the wrong side of the line, though"?

I turn OR <ON> specifically near the end of the macro, because I usually work with OR,++. Whereas with SG, I grab the current state, turn it <OFF> for the macro, then back to pre-macro state near the end. You could do the same thing with OR.

"I prefer that vectors be on a par with commands such as L1" - I don't quite understand this sentence, and your use of "vector", or this "That's why I believe that vectors should be built into GCP and have their own, independent settings."

I address your concern in your last paragraph with:

DQ,SA,TEMP,!;

and

DQ,LO,TEMP,!;

Save current Dimension settings, and load them back in after the macro is run.

I'm not sure why I never used /SET & /GET. I spent many hours pouring over Bjorn's excellent Macro Help file, that's for sure.
Tom Albright
Tom Albright
 
Posts: 92
Joined: Mon Jun 02, 2014 6:53 pm
Location: Billings, MT

Re: Macros

PostPosted by Tom Albright » Wed May 11, 2016 1:38 pm

Here's my curved leader Macro (no text):

/XMD,++,/CHD,--,;
DQ,SA,TEMP,!;
;LW,!,/VRL,6,$VAL,LW,0,;
LW,!,/VRL,6,$VAL;
LT,!,/VRL,5,$VAL,LT,0,;
LL,!,/VRL,4,$VAL,LL,0,;
SG,??,/VIN,2,$VAL,;
TZ,!,/VRL,3,$VAL,;
US,R,A,T,F,A,15,L,$R(3)*.75,!,U,++,!,!;
UL,-1,;
OR,--,SG,--,;
TC,!,/VIN,1,$VAL,;
LC,!,/VIN,0,$VAL,LC,$I(1),;
DQ,DP,R,C,$I(1),!;
;US,C,$I(1),!,;
A3,@,@,@;
SC,@;
/IF,$DERR[EQ]-2,/GTO,XXXX;
/XMD,--,;
LE,!,LP,SO,@;
.XXXX; NOTE THAT "EXIT" CAUSED TEXT TO EXPLODE IN CERTAIN CASES (5/2011)
LC,$I(0),;
OR,++,;
SG,++,/IF,$I(2)[EQ]0,SG,--,;
LL,$R(4),;
LW,$R(6),;
LT,$R(5),;
DQ,LO,TEMP,!;

I have some extra error control in there, so I can hit ESC after i draw the arc, and then run the macro again to draw a second "S" curve and then complete the macro arrowhead. This macro maintains current LT and LW states.

Note that these macros have evolved over the years, starting in Generic CADD, and are some of my most used macros.
Last edited by Tom Albright on Wed May 11, 2016 3:59 pm, edited 1 time in total.
Tom Albright
Tom Albright
 
Posts: 92
Joined: Mon Jun 02, 2014 6:53 pm
Location: Billings, MT

Re: Macros

PostPosted by Ficx » Wed May 11, 2016 2:51 pm

Tom,

Sorry that I didn't study your Temp.cfg file. I now see your attempt at ensuring that the environment is returned to it's prior state as much as possible. Leaving OR on at the end is your personal taste. In my case, I tend to work in REL, with OR off, among other settings.

As for 'What do you mean by, " The arrowhead is on the wrong side of the line, though"?' I explained this in one of my posts dated May 9:

"Both work in the sense of from here to there; that is, the first point is the tail, the second is the head."

Bjorn understood it, as his macro took this into account in the lines

.ARROWLINE;
/VPT,1,@,L1,LP,@,OO; Tail to Arrow points
LE,,LP,$X(1),$Y(1),; Leader with reversed points

You state

'I don't quite understand this sentence, and your use of "vector", or this "That's why I believe that vectors should be built into GCP and have their own, independent settings." '

Let me explain. I'm not an architect, engineer or draftsman. My first encounter with Generic Cadd occurred when I was was doing graduate work in a physics laboratory in the early 1990s. The software was installed in one of the computers in the lab. All graduate students used the software to make drawings for their presentations and some publications in research journals. With many other software now available for this purpose, Generic Cadd's replacements (including General Cadd Pro) are not as appealing.

Mathematicians and physicists also have to make sketches and drawings. This is not the exclusive realm of architects, engineers and draftsmen. Arrows (or vectors as I've been calling them) are used quite frequently by people like myself.

What I'm attempting to do here is to make GCP more appealing to science practitioners by having a few more basic tools included in the software by default, not through macros. The power of macros would consequently be enhanced, I believe, by the inclusion of vectors through dedicated built-in two-letter commands. In other words, the macros that you and Bjorn wrote should be part of an update to GCP, done by the programming team of Matt and Carl. It's not a bad thing to increase the user base by making the software more attractive to others.

Ficx

P.S. I just saw your post for the curved leader macro. I'll check it out tonight after I get back home.
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Lew » Wed May 11, 2016 3:08 pm

Back in the day when my physics was more "general" than "engineering," a vector's identity had a "superscripted bar" above it. That would be a function of the font. That is something that, while not trivial, is quite doable with General CADD. I did that with my own fonts to include all the ASME/ANSI Y14.5/Y14.100 feature control symbology as extended character fonts. Their should be a "tutorial" on how to do this somewhere in the files area here.
Lew
 
Posts: 31
Joined: Sun May 25, 2014 3:09 pm

Re: Macros

PostPosted by Tom Albright » Wed May 11, 2016 3:37 pm

Ficx,

Thank you for your definition of vector. I went back and re-read everything. Vector is what we in the drafting world call a leader (less the shoulder).

I'm all for having more people and uses for GCP; Any way to expand the user base is a big plus for the future of the program.

There has been some attempt at separating leaders from dimensions, as you can see if you dive deeply in DQ and its tabs. It remains a bit buggy, especially when changing colors.

I do agree that hard-coding macros into the software would be a better approach. However, currently, manpower is limited, with Matt only part time and Carl no longer with the team. When we want something done, we turn to macros. If we have enough justification for a function, Matt will consider making it a specific command. I believe you can accomplish a lot with the saving of custom DQ settings, then applying those in a macro. See "Macro Help" at the bottom of the DQ dialog window for macro commands within DQ.

Also, look at using LD, instead of LE. LD draws leader first; LE places text first. LD in a macro could blow past the shoulder direction and text placement and you'd end up with a rubberbanding leader. Its just drawn reverse of what you want. LD also has polyline and curve options in the 3rd prompt line.

Try this - Its not initially in the order you want, but you get rubberbanding and eventually arrow point last.

DC,M,A,!;
/VLC;
OR,--;
/VPT,1,@;
LD,$X(1),$Y(1),@,!,#;
MP,$X(1),$Y(1),;
DC,M,R,!;
Tom Albright
Tom Albright
 
Posts: 92
Joined: Mon Jun 02, 2014 6:53 pm
Location: Billings, MT

Re: Macros

PostPosted by Ficx » Thu May 12, 2016 12:46 pm

Tom,

I tried your curved leader macro. It's different from what I was proposing. I meant an arc with an arrowhead at one of the two ends (a bent arrow).

Thanks for explaining the situation. I had no idea that Matt was by himself now and working on GCP only part-time. Its sad. I should have brought this up again sooner -- a couple of years sooner. Well, perhaps Matt will decide to add to GCP a rudimentary version of vectors before throwing in the towel. Something like we've been discussing, including rubberbanding and vector color set by the current line color, filled arrowhead set at 15 degrees, like in your macro. I'm hoping he does -- some day.

Thanks to Bjorn and to you for posting the sample macros relating to my suggestions. I've learned new things and will explore further. Maybe the two of you can post these sample macros in the User Files section on the GCP web site so that others can have easy access. Sometimes it's not easy finding specific things in a forum; one often just stumbles upon them.

Ficx
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Ficx » Fri May 13, 2016 1:17 am

Bjorn and Tom,

I combined your two macros and came up with this:

;********* This macro draws vectors (lines with arrowheads). The vector
;********* color matches the current line color and the arrowhead size
;********* is proportional to the current text size.
/VLC;
;********* Get status/numerical values of settings so can reset them later
DQ,SA,TEMP,!; Save current dimensions settings to \cfg\dims\temp.cfg
/GET,ManualEntryMode;
/VIN,1,$VAL; current Entry Mode stored in $I(1)
/GET,TextSize;
/VRL,2,$VAL; current text size stored in $R(2)
LC,!,/VIN,2,$VAL; current line color setting in $I(2)
;********* Set leader parameters
US,C,$I(2); set leader color to current line color
US,R,A,A,15,!,!,!; Arrow angle set to 15 degrees
US,R,S,0,A,T,F,L,$R(2)*0.75,,,; ShoulderLength set to 0, Arrow Filled ArrowLength = $R(2)*0.75
;********* Construct vector (arrow)
MO; set manual entry mode to Absolute
/VPT,1,@,L1,LP,@,OO; Tail to Arrow points
LE,,LP,$X(1),$Y(1),; Leader with reversed points
;********* Reset environment
/SET,ManualEntryMode,$I(1);
DQ,LO,TEMP,!; restore dimensions settings
RD;

Ficx
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Bjorn Holmgren » Fri May 13, 2016 4:58 am

Trying AD, as Dave suggegsted, This draws an Arc with end point Arrow.
/SETs and /GETs are just to my preferences.

;*** ARROWARC.GXM Bjorn Holmgren 2016
.SETTINGS;
/SET,ArrowDisplay1,0; = 0
/SET,ArrowDisplay2,0; = 1
/SET,ExtDisplay1,0; = 0
/SET,ExtDisplay2,0; = 0
;;;/SET,ArrowType,2;
AR,T,O,;
/SET,DimLineDisplay,1; = 1
/SET,TextDisplay,0; = 0
/SET,AngularArcLengthSymbolPosition,0; = 0
;*************************************************
.ARROWARC;
A3,@,#;
/VPT,1,LP;
A3,$X(1),$Y(1),@,#;
/VPT,2,LP;
A3,$X(1),$Y(1),$X(2),$Y(2),@;
/VPT,3,LP;
SE,T,!;
AD,$X(3),$Y(3),$X(2),$Y(2);
ER,L,!,RD;
M3,$X(1),$Y(1),$X(2),$Y(2),$X(3),$Y(3);
/IF,$VAL[LE]180,UG,T,!,A2,++,A1,--,!;
/IF,$VAL[GT]180,UG,T,!,A2,--,A1,++,!;
UG,T,!,TX,&,!;
;*************************************************
.RESETS;
/SET,ArrowDisplay1,0; = 0
/SET,ArrowDisplay2,1; = 1
/SET,ExtDisplay1,1; = 0
/SET,ExtDisplay2,1; = 0
;;;/SET,ArrowType,2;
AR,T,S,;
/SET,DimLineDisplay,1; = 1
/SET,TextDisplay,1; = 0
/SET,AngularArcLengthSymbolPosition,0; = 0
DQ,TX,'#',!; Does not work ! ???
Last edited by Bjorn Holmgren on Thu May 19, 2016 4:30 am, edited 1 time in total.
Bjorn Holmgren
 
Posts: 50
Joined: Fri Jun 06, 2014 11:04 am
Location: Sunshine Coast QLD Australia

Re: Macros

PostPosted by Bjorn Holmgren » Fri May 13, 2016 5:01 am

Doing the stright line arrow as a naked dimension instead of as a leader.
Could possibly be helpful with same type as the arc arrow in subsequent manipulations.
/SETs and /GETs to my preferences.

;*** ARROWLINE DIM.GXM Bjorn Holmgren 2016
MO,/VLC;
.SETTINGS;
/SET,ArrowDisplay1,0; = 0
/SET,ArrowDisplay2,1; = 1
/SET,ExtDisplay1,0; = 0
/SET,ExtDisplay2,0; = 0
;;;/SET,ArrowType,2;
AR,T,O,;
/SET,DimLineDisplay,1; = 1
/SET,TextDisplay,0; = 0
/SET,AngularArcLengthSymbolPosition,0; = 0
;*************************************************
.ARROWLINE DIM;
L1,@,#;
/VPT,1,LP;
L1,$X(1),$Y(1),@;
/VPT,2,LP;
OO;
A1,$X(1),$Y(1),$X(2),$Y(2),&,;
M2,$X(1),$Y(1),$X(2),$Y(2);
/IF,$VAL[LE]90,UG,T,!,A2,++,A1,--,!;
/IF,$VAL[GT]90,/IF,$VAL[LE]270,UG,T,!,A2,--,A1,++,!;
;*************************************************
.RESETS;
/SET,ArrowDisplay1,0; = 0
/SET,ArrowDisplay2,1; = 1
/SET,ExtDisplay1,1; = 0
/SET,ExtDisplay2,1; = 0
;;;/SET,ArrowType,2;
AR,T,S,;
/SET,DimLineDisplay,1; = 1
/SET,TextDisplay,1; = 0
/SET,AngularArcLengthSymbolPosition,0; = 0
Last edited by Bjorn Holmgren on Thu May 19, 2016 4:18 am, edited 2 times in total.
Bjorn Holmgren
 
Posts: 50
Joined: Fri Jun 06, 2014 11:04 am
Location: Sunshine Coast QLD Australia

Re: Macros

PostPosted by Bjorn Holmgren » Sat May 14, 2016 2:39 am

:roll: ouch! The ARROWLINE DIM macro was not completely sorted out.
Corrected below.

These 2 macros could now of course be combined into one with Selections [S]traight and [A]rc. and repetitive action.
Bjorn Holmgren
 
Posts: 50
Joined: Fri Jun 06, 2014 11:04 am
Location: Sunshine Coast QLD Australia

Re: Macros

PostPosted by Ficx » Wed May 18, 2016 4:02 pm

Bjorn, do you know if the /GET and /SET commands that are not working will be fixed? Does Matt know about them? I sent a report, but don't know if it was received.
Your ArrowLine Dim macro seems to work fine. But, it does suffers from the same problem as mine, below: if one cancels the macro by hitting Esc, an arrowhead artifact appears and must be manually erased. I don't know how to get the macro get rid of it.

______________________________

The following macro uses LD, instead of LE, to draw a vector. It allows for rubberbanding, as Tom suggested, but the ability to right-click the first of the two points cleanly is lost (other things are dragged along by the MP command). If anybody can fix this, please share your revised (or new) macro.

/MSP,++,/XMD,++;
/VLC;

.GET_INITIAL_VALUES;
/GET,ManualEntryMode;
/VIN,1,$VAL; current Entry Mode stored in $I(1)
/GET,TextSize;
/VRL,1,$VAL; current text size stored in $R(1)
LC,!,/VIN,2,$VAL; current line color setting in $I(2)

.SET_VALUES;
US,C,$I(2); set leader color to current line color
US,R,A,A,15,!,!,!; Arrow angle set to 15 degrees
US,R,S,0,A,T,F,L,$R(1)*0.75,,,; ShoulderLength set to 0, Arrow Filled ArrowLength = $R(2)*0.75
MO,RD; set manual entry mode to Absolute

.PROMPTS;
/PMT,1,' : Vector',#; prompt line 1
/PMT,2,'Left-click for tail end of vector...then the head...',#; prompt line 2

.CREATE_VECTOR;
/VPT,1,@;
LD,$X(1),$Y(1),LP,!,#;
MP,LP,@;

.RESET; (incomplete)
/SET,ManualEntryMode,$I(1);

.END;
RD;
/XMD,--,/MSP,--,PU;


Ficx
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Tom Albright » Wed May 18, 2016 7:42 pm

You'll want to read Bjorn's macro help file section on Error Control. I used this:

/IF,$DERR[EQ]-2,/GTO,XXXX; This detects ESC press and goes to XXXX

...below to attempt to gracefully end the macro. Seems like you need two Escapes, though sometimes it works with one. Moving that line around to different places may solve the issue.



/MSP,++,/XMD,++;
/VLC;
.GET_INITIAL_VALUES;
/GET,ManualEntryMode;
/VIN,1,$VAL; current Entry Mode stored in $I(1)
/GET,TextSize;
/VRL,1,$VAL; current text size stored in $R(1)
LC,!,/VIN,2,$VAL; current line color setting in $I(2)
.SET_VALUES;
US,C,$I(2); set leader color to current line color
US,R,A,A,15,!,!,!; Arrow angle set to 15 degrees
US,R,S,0,A,T,F,L,$R(1)*0.75,,,; ShoulderLength set to 0, Arrow Filled ArrowLength = $R(2)*0.75
MO,RD; set manual entry mode to Absolute
.PROMPTS;
/PMT,1,' : Vector',#; prompt line 1
/PMT,2,'Left-click for tail end of vector...then the head...',#; prompt line 2
.CREATE_VECTOR;
/VPT,1,@;
/IF,$DERR[EQ]-2,/GTO,XXXX; This detects ESC press and goes to XXXX
LD,$X(1),$Y(1),LP,!,#;
MP,LP,@;
.RESET; (incomplete)
/SET,ManualEntryMode,$I(1);
.END;
.XXXX;
RD;
/XMD,--,/MSP,--,PU;

I thought the macro worked pretty well - Please explain:

"the ability to right-click the first of the two points cleanly is lost (other things are dragged along by the MP command)"
Tom Albright
Tom Albright
 
Posts: 92
Joined: Mon Jun 02, 2014 6:53 pm
Location: Billings, MT

Re: Macros

PostPosted by Ficx » Wed May 18, 2016 9:51 pm

Thanks, Tom. /IF,$DERR[EQ]-2,/GTO,XXXX; does the trick.

By "the ability to right-click the first of the two points cleanly is lost (other things are dragged along by the MP command)" I mean that if there's a line or any other entity from which one wishes to start the vector (first click) and one uses the right-hand button (or NP) to snap to that entity, then the entity is changed because it's dragged along with the vector head. It's as if the SS or WS commands were acting. The culprit is the line MP,LP,@; in my macro.

You can draw a line, then run the macro and enter the first point by right-clicking (or using NP) on one of the line's endpoints or the midpoint to see what I mean.


Ficx
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Bjorn Holmgren » Thu May 19, 2016 4:46 am

Ficx,
Sorry, I did not consider the snap issue.
/VPT, does not offer the snaps ...
Many commands may be used like :
/VPT,1,TK,@,PU;
PO,@,OO,/VPT,1,LP;
L1,@,#,/VPT,1,LP;
A3,@,#,/VPT,1,LP;
TK,@,PU,/VPT,1,LP;
Have your pick or dream up your own.
i have adjusted the 2 macros below accordingly.

I am not in a position to answer your questions re updates to GCP,
Bjorn
Bjorn Holmgren
 
Posts: 50
Joined: Fri Jun 06, 2014 11:04 am
Location: Sunshine Coast QLD Australia

Re: Macros

PostPosted by Tom Albright » Thu May 19, 2016 1:29 pm

Ficx,

Open up GCP and paste the macro into GG, the macro editor. Here you can play with different settings and code lines to get the functionality you desire.

I will look into the snap issue as time permits, but these things have a way of sucking up massive amounts of time.

To whom did you send the bug report?
Tom Albright
Tom Albright
 
Posts: 92
Joined: Mon Jun 02, 2014 6:53 pm
Location: Billings, MT

Re: Macros

PostPosted by Ficx » Fri May 20, 2016 1:18 pm

I sent the report to contact@generalcadd.com.

And, you're right, Tom, these things can be very time consuming.
I had already tried the /IF,$DERR[EQ]-2,/GTO,XXXX; command that you
pointed out, but I couldn't get it to work. It was very frustrating because I had
used it a couple of times before in some other macros and it worked. This time I labored over it for too long. That's when I gave up and posted about the artifact appearing after pressing the Esc key.

Most likely I had misspelled something. Copying and pasting from your post solved it. I should have done that using one of my other macros, but it didn't cross my mind because it's such a short command that I should have been able to detect any typos.

Anyway, as it stands, the macro basically does what I wanted it to do. It's not perfect and
one has to understand its limits. And I can always revert to my original vector macro (or Bjorn's version), which doesn't have the snap problem. But, ultimately, nothing beats having Matt hard-wire this functionality into GCP; that would be great!

Ficx
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Tom Albright » Fri May 20, 2016 1:44 pm

I alerted Matt as to your bug report. He had not seen it as of yesterday.

If you can sell your idea to him, more power to you.

I don't recognize your name from the past GC6/GCP forums. Kinda wondering who you are.
Tom Albright
Tom Albright
 
Posts: 92
Joined: Mon Jun 02, 2014 6:53 pm
Location: Billings, MT

Re: Macros

PostPosted by Ficx » Sat May 21, 2016 2:04 am

Thanks, Tom, for bringing it to Matt's attention.

I'm one of the old beta testers. Matt may remember me when he sees my name in the bug report I sent.

Ficx
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Ficx » Mon Jun 06, 2016 10:44 am

Here's a revised version of the vector macro. I left all comments in place.

;*** DISPLACEMENT_VECTOR.GXM
;*** This macro creates a vector (line with an arrowhead). The user selects
;*** the tail end first, then the tip of the arrowhead. The macro is meant
;*** to be used via left click and right snap. As MB is invoked with the
;*** tail end as base point, the arrowhead may also be entered using the tip's
;*** (x,y) values. Vector color is the same as the current line color and the
;*** arrowhead size is controlled by the current text size (TS). Arrow angle
;*** is set to 15°, filled. One can explode the vector if one wants to do a
;*** snap object, say, somewhere on the vector line. Vector line width is the
;*** same as the current line width.
;*** As the macro alters some dimensions settings, all current dimensions
;*** settings are copied to the file \cfg\dims\disp_vec.cfg in the general cadd
;*** folder prior to any changes and then reset. If the DIMS folder doesn't exist,
;*** the user must create it.

/MSP,++,/XMD,++;
/VLC;

.GET_INITIAL_VALUES;
DQ,SA,disp_vec,!; Save current dimensions setting to \cfg\dims\disp_vec.cfg
/GET,ManualEntryMode;
/VIN,1,$VAL; current Entry Mode stored in $I(1)
/GET,TextSize;
/VRL,1,$VAL; current text size stored in $R(1)
LC,!,/VIN,2,$VAL; current line color setting stored in $I(2)
/GET,LineWidth;
/VIN,3,$VAL; current line width setting stored in $I(3)

.SET_VALUES;
/SET,UseDimLineWidth,1; Turn "on" use of dimension line width setting
/SET,DimLineWidth,$I(3); Set Dimension line width to current line width
/SET,UseLeaderArrowWidth,1;
/SET,LeaderArrowWidth,0;
US,C,$I(2); Set leader color to current line color
US,R,A,A,15,!,!,!; Arrow angle set to 15 degrees
US,R,S,0,A,T,F,L,$R(1)*0.75,,,; ShoulderLength set to 0, Filled Arrow, ArrowLength = $R(1)*0.75
MB,RD; set Manual entry mode to Basepoint

.PROMPTS;
/PMT,1,'Displacement Vector (propose VV as 2-letter command)',#; prompt line 1
/PMT,2,'Click the tail-end of the vector...then the head...',#; prompt line 2

.CREATE_VECTOR;
L1,@,#,/VPT,1,LP; Sets the intended tail end of displacement vector.
BP,LP; Sets base point at the intended tail end of disp. vector--temporary (0,0).
LD,0.0001,0,LP,!,#; Starts the tail end slightly displaced from base point [at (0.0001,0)] and the arrowhead at the basepoint using LP.
MP,LP,@; Moves arrowhead to desired position
/IF,$DERR[EQ]-2,OO,/GTO,RESET; Detects ESC press and goes to RESET to terminate macro.
MP,0.0001,0,0.0001,0,0,0; Places the tail end at the base point (leaves a small gap at tail end if use snap for each of the endpoints)
MP,0.0001,0,0.0001,0,0,0; Repeating this seems to solve the gap problem.

.RESET;
/SET,ManualEntryMode,$I(1);
DQ,LO,disp_vec,!; restore dimensions settings

.END;
RD;
/XMD,--,/MSP,--,PU;
Last edited by Ficx on Tue Jun 14, 2016 9:51 pm, edited 5 times in total.
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Ficx » Mon Jun 06, 2016 10:47 am

My version of arc with arrowhead:

;*** ARC_VECTOR.GXM
;*** This macro creates an arc with an arrowhead. The user creates an arc via
;*** A2. The color is the same as the current line color and the arrowhead
;*** size is controlled by the current text size (TS). Arrow angle is 15°,
;*** filled. All current dimensions setting are copied to the file
;*** \cfg\dims\arc_vec.cfg in the general cadd folder prior to any changes and
;*** subsequently reset. If the DIMS folder doesn't exist, the user must create it.

/MSP,++,/XMD,++;
/VLC; Clears local variable space

.GET_INITIAL_VALUES;
DQ,SA,arc_vec,!; Save current dimensions setting to \cfg\dims\arc_vec.cfg
/GET,ManualEntryMode;
/VIN,1,$VAL; current Entry Mode stored in $I(1)
/GET,TextSize;
/VRL,1,$VAL; current text size stored in $R(1)

.SET_VALUES;
;/SET,ArrowType,1; not recognized
/SET,ArrowAngle,15;
US,A,T,F,,,; set arrow type to filled
LC,!,/VIN,2,$VAL; store current line color setting in $I(2)
US,C,$I(2); set dimension color to current line color
;MO; causes problems if place MO here--arc placed way out there if started in MR!
US,A,L,$R(1)*0.75,,,; Set arrowLength = $R(1)*0.75

.PROMPTS;
/PMT,1,' Arc_Vector (propose AV as 2-letter command)',#; prompt line 1
/PMT,2,' Enter arc center...followed by start of arc...then end of arc...',#;
A2,@,@,@; Place Arc
/IF,$DERR[EQ]-2,/GTO,RESET; (-2 if ESC is pressed)Press ESC once or twice; jumps to .RESET;
MO;

;******* Extract information from last entity placed (the arc) *******
/LST; make list of last component details and extract the following info:
/EEX,1,P,1,A,/VPT,1,$PNTX,$PNTY; start of arc, $X(1),$Y(1)
/EEX,1,P,2,A,/VPT,2,$PNTX,$PNTY; arc length midpoint, $X(2),$Y(2)
/EEX,1,P,3,A,/VPT,3,$PNTX,$PNTY; end of arc, $X(3),$Y(3)
/EEX,1,V,1,A,/VPT,4,$STR; arc (circle) center point, $X(4),$Y(4)
/EEX,1,V,2,A,/VRL,4,$STR; arc radius, r, $R(4), not used in this macro
/EEX,1,V,3,A,/VRL,5,$STR; arc span angle, theta, $R(5)

.CREATE_ARC_VECTOR;
/IF,$R(5)[GT]0,DD,L,--,R,++,E,--,X,--,!;
/IF,$R(5)[LT]0,DD,L,++,R,--,E,--,X,--,!;
/IF,$ABS($R(5))[GT]180,/IF,$ABS($R(5))[LT]360,/IF,($X(1)+$X(3))/2[GT]$X(4),EL,AX,$X(4),$Y(4),$X(1),$Y(1),$X(3),$Y(3),$X(4)-$R(4),$Y(4),&,$X(4)-$R(4),$Y(4),PU,/GTO.RESET;
/IF,$ABS($R(5))[GT]180,/IF,$ABS($R(5))[LT]360,/IF,($X(1)+$X(3))/2[LT]$X(4),EL,AX,$X(4),$Y(4),$X(1),$Y(1),$X(3),$Y(3),$X(4)+$R(4),$Y(4),&,$X(4)+$R(4),$Y(4),PU,/GTO.RESET;
/IF,$ABS($R(5))[LT]180,EL,AX,$X(4),$Y(4),$X(1),$Y(1),$X(3),$Y(3),$X(3),$Y(3),&,!,/GTO.RESET;
/IF,$ABS($R(5))[EQ]180,EL,AX,$X(4),$Y(4),$X(1),$Y(1),$X(3),$Y(3),$X(2),$Y(2),&,$X(2),$Y(2);

.RESET;
/SET,ManualEntryMode,$I(1);
DQ,LO,arc_vec,!; restore dimensions settings

.END;
RD;
/XMD,--,/MSP,--,PU;


Ficx
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Ficx » Sun Jun 12, 2016 8:51 pm

From a macro command line like

MP,LP,@;

is there any way to distinguish the method of point entry used by the user--
left-click, coordinates, right-click (NP)?
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm

Re: Macros

PostPosted by Ficx » Mon Jun 13, 2016 11:54 am

Solved an issue with macro DISPLACEMENT_VECTOR.GXM posted on 6 June. The revised macro has been implemented above in the post dated 6 June. This is the final version.

Ficx
Ficx
 
Posts: 17
Joined: Sat May 07, 2016 1:36 pm


Return to General CADD Forum

Who is online

Users browsing this forum: No registered users and 0 guests

cron