Jump to content

Recommended Posts

Posted

We have some code here that inserts blocks based on points in ACAD, and I'm trying to adjust my code for certain points to draw lines. It's a rather long code, so I'm only going to attach that parts specific to drawing a line.

 

;;;-----------------  MyGPSLineLayer      MyLineLayer
(EXAGS_LineFunction "gps-entrance"        "FOC")

(defun EXAGS_CreateBaselineSet ()
   (setq exagsBaselineSet
        (ssget "_X" (list
               (cons 0 "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,POLYLINE,SPLINE")
               (cons 8 "GPS-ROAD,BASELINE,EOG,EOP,FOGLINE,FOC")
               )))
   )

(defun EXAGS_LineFunction (myGPSLineLayer myLineLayer)
     (if
   (setq pointSet (ssget "_X" (list (cons 0 "POINT")(cons 8 myGPSLineLayer))))                            ; declare the set (pointSet)
   (progn                                                            
       (setq cntr 0)                                                    
       (while (< cntr (sslength pointSet))
         (setq ename (ssname pointSet cntr))
         (setq enlist (entget ename))
         (setq pt (cdr (assoc 10 enlist)))
         (setvar "clayer" myLineLayer) 
         (setq pt2 (vlax-curve-getClosestPointto exagsBaselineSet pt))
         (command "_pline" pt pt2)
         (setq cntr (+ cntr 1))
         )
     )
   )
 )

Currently, I'm getting an error: unable to get ObjectID:

set: 6ca>

 

Any assistance is appreciated,

Thanks

Posted

(setq pt2 (vlax-curve-getClosestPointto [color="red"]exagsBaselineSet[/color] pt))

Type of exagsBaselineSet should be vla-object and not Selection set

If I understand the problem

(defun EXAGS_LineFunction (myGPSLineLayer myLineLayer ObjList)
     (if
   (setq pointSet (ssget "_X" (list (cons 0 "POINT")(cons 8 myGPSLineLayer))))                            ; declare the set (pointSet)
   (progn
      (repeat (setq cntr (sslength exagsBaselineSet))
 (setq ObjList (cons (ssname exagsBaselineSet (setq cntr (1- cntr))) ObjList))
 )
      (setq ObjList (mapcar 'vlax-ename->vla-object ObjList))
      (setq cntr 0)
      (setvar "clayer" myLineLayer)
       (while (< cntr (sslength pointSet))
         (setq ename (ssname pointSet cntr))
         (setq enlist (entget ename))
         (setq pt (cdr (assoc 10 enlist)))
         (foreach Obj Objlist
    (setq pt2 (vlax-curve-getClosestPointto Obj pt))
    (command "_pline" "_none" pt "_none" pt2 "")
    )
         (setq cntr (+ cntr 1))
         )
     )
   )
 )

Posted

Thanks!

 

There is a small issue occuring, where the line is being drawn, not only to the nearest line, but lines further away as well.

 

GPS Line.jpg

Posted

Any suggestion on how to fix this?

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...