Jump to content

Simple lisp routine


stevo99

Recommended Posts

Hi All,

 

I am trying to write my first lisp to draw a basic portal frame.

I have used excel to work out the coordinates and construct a command which once I get the drawing command working, I will then do the background math in lisp.

 

For now though, I have the following command that doesn't seem to work and I can't see why.

 

(command "pline" (getpoint "\nPick Base Point: ") "@0,7630" "@14143.5,1237.4" "@14143.5,-1237.4" "@0,-7630" "@530,0" "@0,8208.4" "@-14673.5,1769.4" "@-14673.5,-1769.4")

 

It draws a pline as desired but for some reason the "@530,0" point is placed over the previous one and the pline draws over itself. Any ideas?

 

Also when i paste the command from excel it executes straight away and gives me error messages:

 

Command: (command "pline" (getpoint "\nPick Base Point: ") "@0,7630" "@14143.5,1237.4" "@14143.5,-1237.4" "@0,-7630" "@530,0" "@0,8208.4" "@-14673.5,1769.4" "@-14673.5,-1769.4")

Pick Base Point:

Unknown command "@0,7630". Press F1 for help.

Unknown command "5,1237.4". Press F1 for help.

Unknown command "5,-1237.4". Press F1 for help.

Unknown command "@0,-7630". Press F1 for help.

Unknown command "@530,0". Press F1 for help.

Unknown command "4". Press F1 for help.

Unknown command "5,1769.4". Press F1 for help.

Unknown command "5,-1769.4". Press F1 for help.

nil

 

Any help is greatly appreciated

Link to comment
Share on other sites

Hi All,

 

I am trying to write my first lisp to draw a basic portal frame.

I have used excel to work out the coordinates and construct a command which once I get the drawing command working, I will then do the background math in lisp.

 

For now though, I have the following command that doesn't seem to work and I can't see why.

 

(command "pline" (getpoint "\nPick Base Point: ") "@0,7630" "@14143.5,1237.4" "@14143.5,-1237.4" "@0,-7630" "@530,0" "@0,8208.4" "@-14673.5,1769.4" "@-14673.5,-1769.4")

 

It draws a pline as desired but for some reason the "@530,0" point is placed over the previous one and the pline draws over itself. Any ideas?

 

Unless I've overlooked something, give this a try:

 

(defun c:FOO (/ pt)
 (if (setq pt (getpoint "\nPick Base Point: "))
   (command "pline" pt "@0,7630" "@14143.5,1237.4" "@14143.5,-1237.4"
            "@0,-7630" "@530,0" "@0,8208.4" "@-14673.5,1769.4"
            "@-14673.5,-1769.4" [color="red"]"@0,-8208.4" "@530,0" "_c"[/color]
           )
 )
 (princ)
)

 

 

 

Cheers

Link to comment
Share on other sites

Thanks BlackBox, thanks for pointing out my math errors too :oops:

 

that still doesn't work though, it's the first "@530,0" coordinate that just doesn't seem to draw properly. See the screenshot below.

 

Capture.jpg

 

essentially I get the inside shape just fine, but where I've circled it just seems to reverse back over itself.

 

If I manually enter the pline command and type in the coordinates it works just fine, just not in this lisp....

Link to comment
Share on other sites

Ahhhhh, Nailed it.

 

It is my "Dynamic input" screwing it up. If I turn that off, it works fine.

I also stuffed up the top apex height too....

 

Do you know why the command doesn't work when I paste from excel though in part 2 of my question??

 

 

Thanks for the help.

Link to comment
Share on other sites

I would take a different tack and use the Polar function to work out the points, starting with length, height, pitch this way no worry about pt co-ords.

 

Just a side note there is lots of stuff out there for drawing structural details like a portal including full connection details etc do a bit of a google.

Link to comment
Share on other sites

I would take a different tack and use the Polar function to work out the points, starting with length, height, pitch this way no worry about pt co-ords.

 

Just a side note there is lots of stuff out there for drawing structural details like a portal including full connection details etc do a bit of a google.

 

Actually now that you mention it polar would be way easier.

My goal here wasn't so much to draw a portal frame but to experiment with lisp to draw something that required a bit of math within the script. I've never written lisp before so figured i'd use it to draw something I draw all the time.

I've been resisting the urge to poke around looking for ready made scripts as I wouldn't be learning lisp then.

 

Cheers

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