PDA

View Full Version : offset civil point object



chrisw.94380
2005-10-24, 02:29 PM
I am trying to write a lisp routine that will place a point a specified distance from then end of a line. What we have been doing in my office is using the lengthen command to extend the line a set distane then placing the point on the end of the line then using the lengthen command to bring the line back to it's originial distance. The problem that I am having is that I am using land desktop and the command I need to use is manual point creation for a civil point object. How do I run this command in lisp and also if anyone had a similiar lisp that could help me out.

Mike.Perry
2005-10-24, 02:33 PM
Hi

Have you looked at the "from" Command option?

Refer to the AutoCAD Online Help File [F1] for information on this option, if required.

Have a good one, Mike

chrisw.94380
2005-10-24, 02:40 PM
cool that command worked really well for me now the only thing I have to do is figure out what I need to type to run the command to create a civil point object in lisp

chrisw.94380
2005-10-24, 03:27 PM
^C^C^C^P(cr_mnl)(zz_sdsk '(cg:setpts:manual)) when I go to the customize menu this is what pops up. How would I write the code to get this to run?

Opie
2005-10-24, 03:43 PM
^C^C^C^P(cr_mnl)(zz_sdsk '(cg:setpts:manual)) when I go to the customize menu this is what pops up. How would I write the code to get this to run?

(cr_mnl)(zz_sdsk '(cg:setpts:manual))
This is the lisp code that is executed when you select this from the menu or toolbar. I don't know all of the commands for LDT. You could try this in your routine to see if it will run. Some lisp routines will not allow you to run it within another lisp routine.

HTH

chrisw.94380
2005-10-24, 04:36 PM
When I ran (cr_mnl)(zz_sdsk '(cg:setpts:manual)) in a lisp and tried to run it. I got the message that the lisp rountine is not available. Is there any way that I am able to run this command. I know it might not be a good idea but maybe assigning this command an alias?

chrisw.94380
2005-10-25, 04:45 PM
I am now able to get the commands to run by first loading the module then C:LDD now my problem is that the "from" command is really working for everything. I am trying to place a point at an offset from the end of a line. I have attached a drawing with a revcloud around the area that is an example. Let me know if you have any questions or need me to clarify.
thank you

Opie
2005-10-25, 04:53 PM
No revision cloud found within your drawing.

chrisw.94380
2005-10-25, 05:01 PM
sorry here is the new drawing

chrisw.94380
2005-11-04, 12:41 AM
does anyone have any ideas on this. Right now I am just lengthing the line by five feet putting my point on the end of the line, then I am lengthining the line negative five feet to bring the line back how it was. So far I have not been able to come up with any ideas

paulmcz
2005-11-04, 02:06 AM
does anyone have any ideas on this. Right now I am just lengthing the line by five feet putting my point on the end of the line, then I am lengthining the line negative five feet to bring the line back how it was. So far I have not been able to come up with any ideas

Quick and dirty:


(defun c:pt (/ p1 p2 p3)
(setq p1 (getpoint "\n Point 1")
p2 (getpoint "\n Point 2")
p3 (polar p2 (angle p1 p2) 5.0))
(command "point" p3)
(princ)
)

If, at the lot 185, you pick endpoint of the line near 10133,9110 at the "Point 1" prompt
and the other point (Point 2) near 10112,9125 (other endpoint of the line), it will insert the point 5 units from the end of the line in direction of that line.
If you have different distances for different lots, it needs some more work.
I hope, I understood your question correctly.
You could also contact me on paulmcz@yahoo.com
Good luck.
Paul.

[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]

paulmcz
2005-11-04, 02:15 AM
Moderator,
please tell me how to insert the code between the Code tags.
Thank you, Paul.

Opie
2005-11-04, 02:17 AM
Moderator,
please tell me how to insert the code between the Code tags.
Thank you, Paul.
Please see the vB code (http://forums.augi.com/misc.php?do=bbcode#code) used on this site.

paulmcz
2005-11-04, 02:34 AM
Thank you
Paul.

Jeff_M
2005-11-04, 02:41 AM
does anyone have any ideas on this. Right now I am just lengthing the line by five feet putting my point on the end of the line, then I am lengthining the line negative five feet to bring the line back how it was. So far I have not been able to come up with any ideasHi Chris,
Give this lisp a try. I tested it on the drawing you posted and it works well for me.


;; Routine to add a CogoPoint a specified distance from the end of a line. The point is set from the
;; end closest to the point that the line is selected from.
;; copyright 2005 by Jeff Mishler, miff@sonic.net
;; This version was written for LandDesktop 2006 and tested in LDD3 as well
(defun c:addoffsetpt (/ acadobj aecapp aecproj inspt points endpt ent pickpt pt ss startpt tmp appstr)
(if (< (atoi (substr (getvar "acadver") 1 2)) 16)
(setq appstr "Aecc.Application")
(setq appstr "Aecc.Application.4")
)
(setq acadObj (vlax-get-acad-object)
aecApp (vla-getinterfaceobject acadObj appstr)
aecProj (vlax-get aecApp "ActiveProject")
points (vlax-get aecProj "CogoPoints");get the Point Database
)
(if (not jmm:offset) (setq jmm:offset 5.0));set default offset distance
(if (setq tmp (getreal (strcat "\Offset distance for points (" (rtos jmm:offset) "): ")))
(setq jmm:offset tmp)
)
(while (setq ss (ssget ":S" '((0 . "LINE"))))
(setq ent (vlax-ename->vla-object (ssname ss 0))
pickpt (last (last (last (ssnamex ss 0))))
startpt (vlax-get ent 'startpoint)
endpt (vlax-get ent 'endpoint)
)
(if (< (distance startpt pickpt) (distance endpt pickpt))
(setq inspt (polar startpt (angle startpt endpt) (- jmm:offset)))
(setq inspt (polar endpt (angle endpt startpt) (- jmm:offset)))
)
(setq pt (vlax-invoke-method points 'add (vlax-3d-point inspt) 2));add the point
)
(vlax-release-object points)
(vlax-release-object aecproj)
(vlax-release-object aecapp)
(princ)
)

Enjoy!
Jeff

chrisw.94380
2005-11-04, 07:05 PM
ran the code and got an error that vll-add not defined. I am running land desktop 2005 here

Jeff_M
2005-11-04, 07:57 PM
Sorry about that chris. I took some code from another lisp and this one really didn't need all that overhead. I modified the code above so try it again. I did test it in both LDD3 and Land2006.

chrisw.94380
2005-11-04, 11:33 PM
I can run the command and am able to specify offset distance but then I get this error

ActiveX Server returned an error: Parameter not optional

Jeff_M
2005-11-04, 11:55 PM
<GRRR> That's what happens when I test on my work box....I left in a constant that was no longer defined, except mine is always defined........ find this:
vll-kCoordinateFormatxyZ
and replace with: 2
I'm modifying the posted code as well.

chrisw.94380
2005-11-07, 02:21 PM
thanks alot I finally got it to work. the only issue I have now is that for the elevation it just puts it as zero and puts a . for the description. I tried to modify the code so that it would prompt you for these values but I was unsuccesful

Jeff_M
2005-11-07, 07:48 PM
You're welcome, Chris.
Here's my final version, at least for a while. It honors the settings for adding points as far as the description and elevation are concerned. Those being Automatic, Manual, None as set under Point Options. Feel free to fool around with it as you wish. Also, when manually entering the data the point will already be inserted with the values set to 0.00 for elev and "" for the desc. Once you enter the correct values the point will be updated, but if you cancel out the point will remain with the unwanted values.


;; Routine to add a CogoPoint a specified distance from the end of a line. The point is set from the
;; end closest to the point that the line is selected from.
;; copyright 2005 by Jeff Mishler, miff@sonic.net
;; This version was written for LandDesktop 2006 and tested in LDD3 as well
(defun c:addoffsetpt (/ acadobj aecapp aecproj inspt points endpt ent pickpt pt ss startpt tmp appstr
aecprefs cogoprefs descmode descval elevmode elevval newstr)
(if (< (atoi (substr (getvar "acadver") 1 2)) 16)
(setq appstr "Aecc.Application")
(setq appstr "Aecc.Application.4")
)
(setq acadObj (vlax-get-acad-object)
aecApp (vla-getinterfaceobject acadObj appstr)
aecProj (vlax-get aecApp "ActiveProject")
aecPrefs (vlax-get aecProj 'preferences)
cogoPrefs (vlax-get aecPrefs 'Cogo)
points (vlax-get aecProj "CogoPoints");get the Point Database
)
(setq descmode (vlax-invoke cogoprefs 'getinteger 4)
elevmode (vlax-invoke cogoprefs 'getinteger 3)
)
(setq descval (vlax-invoke cogoprefs 'getstring 200)
elevval (vlax-invoke cogoprefs 'getdouble 500)
)
(if (not jmm:offset) (setq jmm:offset 5.0));set default offset distance
(if (setq tmp (getreal (strcat "\Offset distance for points (" (rtos jmm:offset) "): ")))
(setq jmm:offset tmp)
)
(while (setq ss (ssget ":S" '((0 . "LINE"))))
(setq ent (vlax-ename->vla-object (ssname ss 0))
pickpt (last (last (last (ssnamex ss 0))))
startpt (vlax-get ent 'startpoint)
endpt (vlax-get ent 'endpoint)
)
(if (< (distance startpt pickpt) (distance endpt pickpt))
(setq inspt (polar startpt (angle startpt endpt) (- jmm:offset)))
(setq inspt (polar endpt (angle endpt startpt) (- jmm:offset)))
)
(setq pt (vlax-invoke-method points 'add (vlax-3d-point inspt) 2));add the point
(cond ((= descmode 1)(progn
(setq newstr (getstring (strcat "\nDescription <" descval ">: ")))
(if (not (eq newstr ""))
(setq descval newstr)
)
(vlax-put pt 'rawdescription descval)
)
)
((= descmode 0) (vlax-put pt 'rawdescription descval))
(t (vlax-put pt 'rawdescription ""))
)
(cond ((= elevmode 1)(progn
(setq newstr (getreal (strcat "\nElevation <" (rtos elevval) ">: ")))
(if newstr
(setq elevval newstr)
)
(vlax-put pt 'elevation elevval)
)
)
((= elevmode 0) (vlax-put pt 'elevation elevval))
(t (vlax-put pt 'elevation -1.0e+020))
)
)
(vlax-invoke cogoprefs 'setstring 200 descval)
(vlax-invoke cogoprefs 'setdouble 500 elevval)
(vlax-release-object points)
(vlax-release-object aecproj)
(vlax-release-object aecapp)
(princ)
)

chrisw.94380
2005-11-09, 02:38 PM
thanks everyone I got exactly what I wanted with this lisp. Now I will be able to save a couple hours of work per week.

chrisw.94380
2006-02-17, 05:03 AM
This command has worked great for me. Is there anyway I can click on a point first and get that points elevations and use it on my point before clicking on the line I want to offset from?

chrisw.94380
2006-03-08, 05:18 AM
I have explored using attribute extraction to obtain the elevation from a previous point but it seems to only work for blocks. I am not sure if I am making sense with this but let me know if anyone has any questions or can steer me in the right direction.

sinc
2006-03-09, 10:51 PM
Are you familiar with the tracking osnaps and direct keyboard distance entry?

You might want to read up on them. The tracking works a bit differently, depending on whether or not you have the "Shift to Acquire" option set in Options.

But basically, you put make sure OTRACK is enabled, then put the cursor over the end of the line. If you have Shift to Acquire enabled, hit the Shift key. You should see a little dashed extension line come out of the end of the line. Key in your distance and hit RETURN.

If I understand your problem correctly, this is all you have to do, and all that Lisp effort was basically just a programming exercise.

sinc
2006-03-09, 11:31 PM
Oops, I think I garbled that explanation a bit.

I kind of mixed up the Extension OSNAP and OTRACK. The little bit I explained above is actually a manifestation of the Extension OSNAP.

OTRACK is a bit different, and relates to temporary tracking points. They're very useful, too, but I don't have time right now to explain them.

Jeff_M
2006-03-09, 11:37 PM
<snip>
If I understand your problem correctly, this is all you have to do, and all that Lisp effort was basically just a programming exercise.That and save having to type the distance at each and every point. If I have 200 lots, each with a sewer & water lateral, and I need to set points to stakeout each lotcorner at 5' offset and each lateral at a 10' offset, that's 500-600 times I'd have to enter an offset distance using OTRACK and make sure the direction vector is going the right way.....whereas I'd only need to input 2 using my lisp.

But thanks for kicking me in the behind, as I had never really looked into the OTRACKing because I just never thought about it. I see where I could've put it to extensive use just this morning......

Jeff_M
2006-03-10, 12:39 AM
One other thing, Richard, I can honestly say I did a "Hey! Where'd that come from?" when I was investigating this earlier today. I use running OSNAPS all the time, so I am always in & out of the Osnap Settings dialog and, until just a while ago, NEVER even noticed the Extension snap! I'll just put this off as another case of "the mind sees what it wants/needs to see".........

And even though I wouldn't have thought to use this method for the OP's question, I sincerely thank you for pointing out the optional method. I know that many of my day to day tasks will be shortened by your eye opening comments.

Jeff

sinc
2006-03-10, 05:34 AM
Yeah, I think the temporary tracking capabilities may possibly be the most useful "overlooked /underutilized feature" of Autocad... :)

Just turn off "Dimension Input" in the Dynamic Input settings if you like having a floating or hidden command window. As I finally discovered through much trial-and-error, the "Dimension Input" portion of the Dynamic Input function in 2006 wrecks havoc with OTRACK and direct distance entry.