Jump to content

Error for ObjectID of polyline using vlax-curve-*


HelplessIntern

Recommended Posts

I have just started learning AutoLISP from different posts on the forums and through the reference material from Autodesk but, I am hitting an error in my lisp routine that I don't know how to fix. I am trying to right a while loop that will go through a nested list and use information in the selected list segment to find points in reference to a Polyline using the vlax-curve-* functions. Currently I am using the vlax-curve-getPointAtDist with a variable distance and using a user defined polyline from the document. My code runs up until the point I try to use the getPointAtDist line which will return the error of "unable to find ObjectID for . The way I get the polyline from the user is a (setq Var (ssget "_+.:s" '((0 . "*POLYLINE")))).

 

I have earlier in the routine the vla-load-com to load in all of the functions of visual lisp.

 

Can anyone help me out on what I need to do to be able to run the vlax-curve-* functions?

Link to comment
Share on other sites

Here is the code that pertains to the variables and while loop.

 

I apologize in advance for very newbie code writing. Thank you for speedy reply.

 

(setq Centerline (ssget "_+.:s" '((0 . "*POLYLINE"))))
 (setq Side nil)
 (setq Counter 0)
 (setq Offset nil)
 (setq Station nil)
 (setq StaLength nil)
 (setq StationKM nil)
 (setq StationM nil)
 (setq BlkName nil)
 (setq ZZ 0.0)
(setq CLAngle nil)
 (setq CAngle nil)
 (setq Coor (list 0.0 0.0 ZZ))
 (setq BaseCopy (list 0.0 0.0 ZZ))
 (setq RefPt (list 0.0 0.0 ZZ))
 (setq AnglePt (list 0.0 0.0 ZZ))
 (while(>=(- IterationNumber Counter) 0)
   ;;(setq CX (+ "offset in x" and "RX"))  I dont think these are useful
   ;;(setq CY (+ "offset in y" and "RY"))  I dont think these are useful
   (setq Entry (nth Counter *ExcelData@))
   (setq BlkName (nth 0 Entry))
   (setq Side (nth 1 Entry))
   (setq Station (nth 2 Entry))
   (setq StaLength (strlen Station))
   (setq StationKM (atoi (substr Station 1 (- StaLength 4))))
   (setq StationM (atoi (substr Station (- StaLength 3))))
   (setq RefPt (vlax-curve-getPointAtDist (vla-get-Objectid Centerline) (+ (* (- StationKM StartKM)1000) (- StationM StartM))))
   (setq AnglePt (vlax-curve-getPointAtDist Centerline (- (+ (* (- StationKM StartKM)1000) (- StationM StartM)) 2)))
   (setq Offset (atof (nth 3 Entry)))
   (setq CLAngle (angle AnglePt RefPt))
   (if(or (= Side "left") (= Side "Left") (= Side "LT") (= Side "L")) 
       (progn (setq CAngle (+ 90 (* 180 (/ CLAngle pi))))) 
       (progn (setq CAngle (+ 270 (* 180 (/ CLAngle pi)))))
   )
   (setq Coor (polar RefPt CAngle Offset))
   (setq BaseCopy (list ((+ (car Coor) Xdiff) (+ (cadr Coor) Ydiff) ZZ)))
   
   (command "_Copy" ObjectPoint "" BasePoint Coor)
   (command "_ROTATE" BaseCopy "" Coor "r" "0" CAngle)
   
   
 )

Link to comment
Share on other sites

When you use the function ssget you need to retrieve the entity name with the function ssname as follows:

 

(ssname Centerline 0) ;; since you are using the single pick mode with ssget, I used zero since you have only one object in the selection set.

 

You need to use the above posted codes instead of the vla-get-objectID function. SEE THIS

Link to comment
Share on other sites

Alright, I assigned a new variable below, and called it in the vlax-curve-getPointatDist also below. I am still getting the error of no ObjectID. Do I need to somehow manipulate the Entity Name?

 

 (setq Centerline (ssget "_+.:s" '((0 . "*POLYLINE"))))
 (setq CLName (ssname Centerline 0))

 (setq RefPt (vlax-curve-getPointAtDist CLName (+ (* (- StationKM StartKM)1000) (- StationM StartM))))

Link to comment
Share on other sites

Alright, I assigned a new variable below, and called it in the vlax-curve-getPointatDist also below.

That is good so far.

 

I am still getting the error of no ObjectID. Do I need to somehow manipulate the Entity Name?

 

Are you sure that you picked the right object name which is polyline in your case or the selection is not equal to nil ? Better to add if function to check if the selection is valid then do the rest of codes.

eg:

(if (setq centerline (ssget "_+.:s" '((0 . "*POLYLINE"))))
 (....... ;; etc 

Link to comment
Share on other sites

Are you sure that you picked the right object name which is polyline in your case or the selection is not equal to nil ? Better to add if function to check if the selection is valid then do the rest of codes.

eg:

(if (setq centerline (ssget "_+.:s" '((0 . "*POLYLINE")))) 
    (....... ;; etc 

I am fairly certain that the selection set is not nil because in AutoCAD I can "!Centerline" and it returns "" however everytime I run the command and choose the same polyline the "##" in the selection set changes. I also can "!CLName" and it returns "" and the entity name is always the same.

 

As for the if loop, this might sound very ignorant, what could I gain from putting the if loop with the test expression above? Won't that just check to make sure there is something in the selection set?

Link to comment
Share on other sites

Yes the if function is to get sure you have valid selection set before moving to the other lines.

 

Can you bring a sample drawing showing what you are trying to accomplish?

Link to comment
Share on other sites

I would suggest following this tutorial to determine the expression at which your code is failing; when the erroneous expression has been determined, we can then assist you to correct it (if you cannot do so yourself).

Link to comment
Share on other sites

Thank you for all of your help. I was able to get the rest of the routine working after your pointers.

Link to comment
Share on other sites

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