Jump to content

Recommended Posts

Posted

Hi,

 

I need to transfer some plumbing (or piping) from Autocad to a another program for specialist analysis. This analysis requires that I have the piping as 1m length pieces.

 

I have found lisp code to measure the line and place a marker (block) every 1 metre, and also have a program to extract the block co-ordinates to a text file (which then allows me to reload the line into the the third party app).

 

However this process cuts all the corners, so my re-constituted line is not exactly what i started with.

 

I need a lisp code that measures the polyline, but also places the block marker at the vertex's of the polyline.

 

As a secondary item is it possible to use text as the block, and modify the text so that it extends 1,2,3,... alond the line, - this would assist me ensure that the line is re-constituted correctly in the third party app - particularly when I want to do several lines at the same time.

 

I've some experience with Autolisp way back at R10, and again R12, but not touched it much in the last 10 years. So I think I could modify code provided, to suit R2006, if you prefer to answer in code only tested on R2010 etc..

 

Cheers!

Posted

You need a check in the code when segmenting to see if it has a remainder less than 1m and then write out the vertice and continue on. It should be doing this now else it would not do the 1m segments unless it uses divide or measure rather than calculating it from first principals, in which case you will need a different program.

 

Can you post current code please.

 

Also search here for "chainages along polyline" may be a good starting point it may do what you want.

Posted

Actually it is just a bit of code around the "measure" command - sorry i didn't make that clear enough. Not sure it will help you significantly. I was trying to edit the text in "tag" to be trk_nam but never really got any where..

 

(setq trk_nam " ")

(defun C:TRACK (/ )

(setq trk_nam (getstring "Name of the Track: "))

(setq dist_pts (getreal "Distance between points: "))

(command "measure" pause "B" "tag" "Y" dist_pts)

)

Posted

Thanks for the search suggestions. I managed to find a thread that gave something close to what I needed, and after some learning about ActiveX :), I've managed to modify it to get what I need.

 

This is what i came up with:

(defun c:pldiv (/ actDoc spFlag actSp poly
        sumDis nextPt oldDist oldNum)
 (vl-load-com)
 (setq actDoc(vla-get-ActiveDocument
         (vlax-get-acad-object))
 spFlag(vla-get-ActiveSpace actDoc)
       ); end setq
(if(= 0 spFlag)
 (setq actSp(vla-get-PaperSpace actDoc))
 (setq actSp(vla-get-ModelSpace actDoc))
); end if
 (if(not pldiv:dist)(setq pldiv:dist 1.0))
 (if(not pldiv:num)(setq pldiv:num 1))
  (setq stFlag T
        sumDis 0.0
 oldDist pldiv:dist
 oldNum pldiv:num
 pldiv:dist
  (getdist
    (strcat
      "\nSpecify distance <"(rtos pldiv:dist)">: "))
 pldiv:num
  (getint
    (strcat
      "\nSpecify start number <"(itoa pldiv:num)">: "))
 ); end setq
 (if(not pldiv:dist)(setq pldiv:dist oldDist))
 (if(not pldiv:num)(setq pldiv:num oldNum))
 (princ "\n*** Select line, polyline or spline *** ")
 (if
   (and
   (setq poly
    (ssget "_:S"
     '((0 . "*LINE")(-4 . "<NOT")(0 . "MLINE")(-4 . "NOT>"))))
   (setq nextPt
   (getpoint "\nSpecify start point at curve > "))
   (vlax-curve-getDistAtPoint
     (setq poly(vlax-ename->vla-object(ssname poly 0)))
     nextPt)
   ); end and    
   (progn
     (setq next_vtx_param 1
  next_vtx_dist (vlax-curve-getDistAtParam poly next_vtx_param)
  ); end setq
     (while nextPt
  (while (> sumDis next_vtx_dist) 
 (progn
 (setq VtxPt(vlax-curve-getPointAtParam poly next_vtx_param))
 (vla-AddPoint actSp(vlax-3d-point VtxPt))
 (vla-AddText actSp (itoa pldiv:num)
    (vlax-3d-point VtxPt)(getvar "TEXTSIZE"))
 (setq next_vtx_param (+ 1 next_vtx_param)
       next_vtx_dist (vlax-curve-getDistAtParam poly next_vtx_param)
       pldiv:num(1+ pldiv:num)
       );end set q
 ) ; end progn
  );end while
(vla-AddPoint actSp(vlax-3d-point nextPt))
(vla-AddText actSp (itoa pldiv:num)
   (vlax-3d-point nextPt)(getvar "TEXTSIZE"))  
(setq  sumDis (+ sumDis pldiv:dist)
 pldiv:num(1+ pldiv:num)
        nextPt(vlax-curve-getPointAtDist poly sumDis)
       ); end setq
      ); end while
     (setq endParam (vlax-curve-getEndParam poly)
           EndPoint(vlax-curve-getPointAtParam poly endParam))
      (vla-AddPoint actSp(vlax-3d-point EndPoint))
(vla-AddText actSp (itoa pldiv:num)
   (vlax-3d-point EndPoint)(getvar "TEXTSIZE"))  
     ); end progn
   (princ "\nERROR. Empty selection, invalid object type or point not at curve. ")
   ); end if
 (princ)
 ); 

  • 4 weeks later...
Posted

This is very very useful for me!!! But i would like to put a text in front of the numers.

 

Is that posible?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...