progeCAD support, tips and troubleshooting forum. progeCAD works very similar to some versions of AutoCAD. Moderated.

Moderators: caddit, Moderators

#1901 by sescott
Thu Dec 27, 2012 11:54 am
Hi everybody,
I am new to CAD and to this forum.
Presently, I am trialling ProgeCad which looks excellent. I am an archaeologist and need to produce drawings with hachures (sometimes called tadpoles) to represent slopes on the ground. I have copied an Auto Lisp routine (saved as a .lsp file) from Phil Howard's book Archaeological Surveying and Mapping which he used to draw hachures in an older version of Intellicad. Unfortunately though, it doesn't seem to work in Progecad. If anyone has any suggestions for drawing hachures in Progecad, I would be extremely grateful.
Kind regards,
Stephen Scott
#1904 by sescott
Thu Dec 27, 2012 2:10 pm
Hi,
Many thanks for coming back to me so quickly. The script is as follows:


;Program to draw hachures
;convert an angle in degrees to radians
(defun dtr (a)

(*pi(/a 180.0))

)
; Acquire information for hachure
(defun hachinf()
(setq (getpoint"\nStart point of hachure. Press ESC to quit:"))
(setq ep (getpoint"\nEndpoint of hachure:"))
;set dimension of hachure head
(setq length (distance sp ep))
(setq hfwidth (/length 15))
(setq hdlength (/length 2.5))
(setq tlength (-length hdlength))
(setq hangle (angle sp ep))
(setq width (*2 hfwidth))
(setq angle1 (+hangle (dtr 90)))
(setq intang1 (atan(/hdlength hfwidth)))
(setq angle2(-hangle (-(dtr 90) intang1)))
(setq slength (/hdlength (sin intang1)))
(setq intang2 (atan(/hfwidth hdlength)))
(setq angle3 (+hangle (dtr 180) intang2))
(setq angle4 (+hangle (dtr 180)))
)
;Draw hachure
(defun drawout()
(command "pline"
(setq p (polar sp angle1 hfwidth))
(setq p (polar p angle2 slength))
(setq p (polar p hangle tlength))
(setq p (polar p angle4 tlength))
(setq p (polar p angle3 slength))
"close"
)
)
;Draw hachures many times
(defun hach ()
(setq numhach 1000)
(setq counter 1)
(while (<=counter numhach)
(hachinf)
(drawout)
(setq counter (+1 counter))
)
)

#1906 by caddit
Fri Dec 28, 2012 6:35 am
sescott,

This looks like a simple script that generates some polylines to given parameters, however there is no command defined (using AutoLISP C:<COMMAND NAME> convention - at the moment it is just a set of internal AutoLISP definitions.

Can you give us an example of HOW this script is supposed to be used? for example, you would need to change:
Code: Select alldefun hach ()
to
Code: Select alldefun c:hach ()


to make it command line accessible. How do you normally call/use this script?
#1908 by sescott
Fri Dec 28, 2012 10:29 am
As I see it, there are four sub routines:
1. Converts degrees to radians
2. Asks for the start and end points of the hachure ( I assume by selecting start and end points with the mouse)
3. Draws the hachure and
4. Is a conditional statement that allows the process to continue until either Esc is pressed or 1000 hachures are drawn

I see what you mean about a command to call the function. I have attempted to embed a line of code C:defun hachure () in the past but still the script would not run. I have also tried to call the script by calling it in parentheses eg. (hachures) from the command line. The script is saved as hachures.lsp.

If the script was run successfully, I would expect to see command prompts asking me to define the start and end points of the hachure.
Many thanks for your time,
Stephen
#1909 by sescott
Sun Dec 30, 2012 10:55 am
Hi,
I have now substituted (defun hachinf() with (C:defun hachinf()

and I am trying to call the function from the command line with the hachinf command.
Something does happen and the following text appears above the command line (the part that is greyed):

Start point of hachure. Press ESC to quit:"))
(C: HACHINF)
Command:

These lines are in the script so at least I am now able to call it. Now I have to find a way to input the start and end points of the hachure. Simply clicking with the mouse does not do it. I have also tried inputting coordinates with the same poor result.
Any help would be much appreciated.
Regards,
Stephen

#1910 by caddit
Mon Dec 31, 2012 6:48 am
Hi sescott,


We had a closer look using progeCAD and saw what seems someone basically made several typos - multiple missing whitespaces (whitespace seperator required between operands and value names) and I think I know where the missing sp definition was supposed to go :?

Tidied up a bit for you, this "works" for us, but please remember that we here know nothing about hachures:
Code: Select all;Program to draw hachures -- as corrected on CADDIT.net forum
;convert an angle in degrees to radians
(defun dtr (a)
  (* pi(/ a 180.0))
)
; Acquire information for hachure
(defun hachinf()
(setq sp (getpoint"\nStart point of hachure. Press ESC to quit:"))
(setq ep (getpoint"\nEndpoint of hachure:"))
;set dimension of hachure head
(setq length (distance sp ep))
(setq hfwidth (/ length 15))
(setq hdlength (/ length 2.5))
(setq tlength (- length hdlength))
(setq hangle (angle sp ep))
(setq width (* 2 hfwidth))
(setq angle1 (+ hangle (dtr 90)))
(setq intang1 (atan(/ hdlength hfwidth)))
(setq angle2(- hangle (-(dtr 90) intang1)))
(setq slength (/ hdlength (sin intang1)))
(setq intang2 (atan(/ hfwidth hdlength)))
(setq angle3 (+ hangle (dtr 180) intang2))
(setq angle4 (+ hangle (dtr 180)))
)
;Draw hachure
(defun drawout()
(command "pline"
(setq p (polar sp angle1 hfwidth))
(setq p (polar p angle2 slength))
(setq p (polar p hangle tlength))
(setq p (polar p angle4 tlength))
(setq p (polar p angle3 slength))
"close"
)
)
;Draw hachures many times
(defun c:hach ()
(setq numhach 1000)
(setq counter 1)
(while (<= counter numhach)
(hachinf)
(drawout)
(setq counter (+1 counter))
)
)


For now I am just guessing the internal "hach" AutoLISP function is the AutoCAD command line "point of entry" for this script (command: hach) but I'm not sure this is right either.. it might be that the user is supposed to write some kind of wrapper for this? Anyway..

BTW, in way of troubleshooting tip for any future scripts you might have - progeCAD will often indicate the problem line if there is a mistake (hit the F2 button to see the full history). This way anyone with a bit of patience to read the fine manual can also fix code line by line until it does what they want...

There is also an AutoLISP reference (for progeCAD) which can be used HERE:
http://help.caddit.net/progecad.php?kb=4A

Hope this helps..
#1911 by sescott
Mon Dec 31, 2012 8:58 am
Hi caddit,
Many thanks for your help. I did not know about the whote space required between operands and value names. I will try the script later today. In the meantime, I have downloaded the Autolisp reference. Your assistance is much appreciated.
Kind regards,
Stephen

#1912 by caddit
Tue Jan 01, 2013 6:37 am
Dear sescott,


I did not know about the whote space required between operands and value names.


No problem, enjoy using progeCAD. BTW the whitespace separator is just standard AutoLISP coding practice - also in AutoCAD. Also like we said, the "sp" value name was completely missing from its own declaration (right after defun hachinf()..). There were other typos as well. As a future note, we don't usually make a practice of cleaning up other people's AutoLISP unless it really has to do with a question about a command, a progeCAD-specific bug or workaround - which is probably not the case with this script, as far as we see so far anyway..