Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LISP routine for matching point properties

18 REPLIES 18
SOLVED
Reply
Message 1 of 19
IanMcClain
3327 Views, 18 Replies

LISP routine for matching point properties

I'm trying to make a LISP routine that will match point style, label style, marker rotation, label rotation and layer for a selected point to multiple other points. I don't know what the exact variable names are or how to find them.

 

See the post below for code that is similar too what I'm looking for.

 

http://forums.autodesk.com/t5/AutoCAD-Civil-3D-Customization/rotating-point-labels-in-2013/m-p/38004...

 

I'm somewhat able to follow this code, just need a little boost. Thanks in advacne for any guidance towards the solution.

Ian McClain
18 REPLIES 18
Message 2 of 19
Jeff_M
in reply to: IanMcClain

Assuming you have the point already that will be the 'source' point saved as 'sourcept':

(setq ptrotation (vlax-get sourcept 'rotation)
      lblrotation (vlax-get sourcept 'labelrotation)
      ptstyle (vlax-get sourcept 'Style)
      lblStyle (vlax-get sourcept 'LabelStyle)
      layr (vlax-get sourcept 'layer)
      )

;;then for each point you want to apply these to:
(vlax-put pt 'rotation ptrotation)
(vlax-put pt 'labelrotation lblrotation)
(vlax-put pt 'Style ptstyle)
(vlax-put pt 'labelstyle lblstyle)
(vlax-put pt 'layer layr)

 

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 19
Partha.Sarkar
in reply to: IanMcClain

Hi ,

 

You can find out the list of all the properties which you can access by referring to AeccPoint in Civil 3D COM API reference doc.

 

Thanks,



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 4 of 19
allanbsteven
in reply to: Jeff_M

Hi Jeff,

I have tried to put these together and I just can't make the code to work. Your rotation tool is terrific.

If you can steer me in the right direction I would appreciate it.

Thanks

Allan

Message 5 of 19
Jeff_M
in reply to: allanbsteven

Allan, post the code you've tried to get working and we'll see what you are missing.

Jeff_M, also a frequent Swamper
EESignature
Message 6 of 19
allanbsteven
in reply to: Jeff_M

Hi Jeff

Any help is much appreciated. I am still learning lisp.

I am trying to match all point properties of a cogo point.

Guys in the field give random codes sometimes or errors and think it would be much quicker to have a match properties lisp.

 

From what I have gathered from previous posts I have put this together

 

 

;;; match point lable style
 (defun c:mst (/ doc ss ss2 obj obj2 newstyle oldstyle)
 (vl-load-com)
 (setq doc (vla-get-activedocument (vlax-get-acad-object)))
 (vla-startundomark doc)
 (while (setq ss (ssget ":S" '((0 . "AECC_COGO_POINT"))))
 (setq obj (vlax-ename->vla-object (ssname ss 0)))
 (setq oldstyle (vlax-get obj 'labelstyle))
(setq oldstyle (vlax-get obj 'labelstyle newstyle))
(setq oldstyle (vlax-get obj 'Style ptstyle))
(setq oldstyle (vlax-get obj 'labelstyle lblstyle))
(setq oldstyle (vlax-get obj 'layer layr))
(princ "\n....select Points to change: ")
(if (setq ss (ssget '((0 . "AECC_COGO_POINT"))))
    (while (> (sslength ss) 0)
 (setq obj2 (vlax-ename->vla-object (ssname ss2 0)))
 (setq newstyle (vlax-get obj2 'labelstyle))
 (vlax-put obj 'labelstyle newstyle)
 (vlax-put pt 'Style ptstyle)
 (vlax-put pt 'labelstyle lblstyle)
 (vlax-put pt 'layer layr)
 (vla-endundomark doc)
 (princ)
 )
 )

 

 

 

 

not sure if we can add raw description also?

Best Regards

Allan

Message 7 of 19
Jeff_M
in reply to: allanbsteven

Allan, hint, use the Insert Code button so your code doesn't get the forum formatting or smileys:

9-4-2014 7-22-46 PM.png

 

Yes, the rawdescription can be added. I am just headed out the door for the night, will have a look late tonight or tomorrow.

 

 

Jeff_M, also a frequent Swamper
EESignature
Message 8 of 19
allanbsteven
in reply to: Jeff_M

Thanks Jeff, I will use that from now one.

Cheers

Allan

Message 9 of 19
Jeff_M
in reply to: allanbsteven

Here's your code, Allan, modified to work correctly. 

 

;;; match point lable style
(defun c:mst (/ doc labelstyle layr lblstyle newstyle obj obj2 pt ptdesc ptlayer ptstyle sourcept ss ss2)
  (vl-load-com)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark doc)
  (princ "\nSelect source point: ")
  (if (setq ss (ssget ":S" '((0 . "AECC_COGO_POINT"))))
    (progn
      (setq sourcePt (vlax-ename->vla-object (ssname ss 0)))
      (setq labelstyle (vlax-get sourcePt 'labelstyle))
      (setq ptstyle (vlax-get sourcePt 'Style))
      (setq ptdesc (vlax-get sourcePt 'rawdescription))
      (setq ptlayer (vlax-get sourcePt 'layer))
      (princ "\n....select Points to change: ")
      (if (setq ss (ssget '((0 . "AECC_COGO_POINT"))))
	(while (> (sslength ss) 0)
	  (setq pt (vlax-ename->vla-object (ssname ss 0)))
	  (vlax-put pt 'labelstyle labelstyle)
	  (vlax-put pt 'Style ptstyle)
	  (vlax-put pt 'rawdescription ptdesc)
	  (vlax-put pt 'layer ptlayer)
	  (ssdel (ssname ss 0) ss)
	)
      )
    )
  )
  (vla-endundomark doc)
  (princ)
)

 

 

Jeff_M, also a frequent Swamper
EESignature
Message 10 of 19
allanbsteven
in reply to: Jeff_M

Jeff,

You are a legend. I will look at this monday. I REALLY apprecite your help.

Best regards

Allan

Message 11 of 19
allanbsteven
in reply to: Jeff_M

Thanks Jeff,

Lisp worked very well. Many thanks.

Regards

Allan

Message 12 of 19
Jeff_M
in reply to: allanbsteven

You're welcome, Alan. If you could throw a Kudos my way on that post, it'd be appreciated.

Jeff_M, also a frequent Swamper
EESignature
Message 13 of 19
IanMcClain
in reply to: Jeff_M

Thanks Jeff Smiley Very Happy

 

How would one change this code so that a default point style or point label style would copy over from the source point? 

Ian McClain
Message 14 of 19
Jeff_M
in reply to: IanMcClain

Ian, unfortunately I have never found a way, in the COM API, to set the styles to the "<default>" property. Essentially, those points have no style assigned, but assigning the style to nil throws an error. Here's an old thread on the matter:

http://forums.autodesk.com/t5/autocad-civil-3d-customization/set-point-group-label-style-to-quot-non...

where it's discussing the VB.NET but they were using the COM API.

 

In the newer .NET API this can be done, but that leaves lisp out.

Jeff_M, also a frequent Swamper
EESignature
Message 15 of 19
mikemcculley5692
in reply to: Jeff_M

Jeff, could you modify this lisp to only match the rotation of the source?

 

Thanks ahead of time.

Message 16 of 19
d_prontnicki
in reply to: Jeff_M

Hi Jeff,

 

This is a great routine. I am trying to modify it so I can use it to freeze the layer that the point label is on. Do you thing you could help me out?

 

Thanks!

Message 17 of 19
Jeff_M
in reply to: d_prontnicki


@d_prontnicki wrote:

Hi Jeff,

 

This is a great routine. I am trying to modify it so I can use it to freeze the layer that the point label is on. Do you thing you could help me out?

 

Thanks!


Do you really want to freeze the label layer? Or, just turn off the display of the label in the Point Style setting? Either way, you will need to get the LabelDisplayStylePlan property from the PointStyle. Then you can get the Layer name or set the Visible property to false. Here are a few lines that can be added to the original code to do this:

      (setq ptstyle (vlax-get sourcePt 'Style))
      (setq lbldisplay (vlax-get ptstyle 'labeldisplaystyleplan))
      (setq layername (vlax-get lbldisplay 'layer))
      ;;add code to freeze that layer, or, just turn it off in the style. Turning it off in the style
      ;; would be best, as the marker and label may both be on the same layer and freezing the layer
      ;; would make the point invisible.
      (vlax-put lbldisplay 'visible 0);;this turns off the display of the label.
      (setq ptdesc (vlax-get sourcePt 'rawdescription))
Jeff_M, also a frequent Swamper
EESignature
Message 18 of 19
d_prontnicki
in reply to: Jeff_M

Jeff,

 

Thank you so much! This helped tremendously! I really appreciate it.

Message 19 of 19
tcorey
in reply to: allanbsteven


@allanbsteven wrote:

Jeff,

You are a legend....


I second that.



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report