Author Topic: line with attribute tool  (Read 10128 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
line with attribute tool
« Reply #15 on: December 02, 2004, 04:38:28 PM »
dubb, it is good coding practice to localize vars that don't need to be global in context.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

dubb

  • Swamp Rat
  • Posts: 1105
line with attribute tool
« Reply #16 on: December 02, 2004, 06:36:46 PM »
so my defun should look like this right?

Code: [Select]

(defun c:bm (/ pt1 pt2 pt3 newpt1 newpt2)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
line with attribute tool
« Reply #17 on: December 02, 2004, 06:47:08 PM »
yeppers
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

dubb

  • Swamp Rat
  • Posts: 1105
line with attribute tool
« Reply #18 on: December 02, 2004, 06:50:43 PM »
yayy!!

so what about setting pt3 as the midpoint of pt1 and pt2?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
line with attribute tool
« Reply #19 on: December 02, 2004, 06:53:58 PM »
Do you not have PT# already set, or is set incorrectly
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

dubb

  • Swamp Rat
  • Posts: 1105
line with attribute tool
« Reply #20 on: December 02, 2004, 07:04:17 PM »
i beleive its set incorrectly

Code: [Select]

(setq pt3 (polar pt1 (angle pt1 pt2) 5))


i know this is not the way, theres gotta be some other function

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
line with attribute tool
« Reply #21 on: December 02, 2004, 07:37:57 PM »
Ok, to get the midpoint of PT1 and PT2, you can use the polar command and the distance command to get the value such as:

Code: [Select]

(setq pt3 (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2)))


Or you can use the algebraic formula

Code: [Select]

(setq pt3 (list (/(+ (car pt1)(car pt2))2)(/(+(cadr pt1)(cadr pt2))2)))
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
line with attribute tool
« Reply #22 on: December 02, 2004, 08:31:49 PM »
dubb
So this line (setq pt3 (polar pt1 (angle pt1 pt2) 5))
Becomes this (setq pt3 (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2)))
And reads like this: pt3 equals a point starting from pt1 at an angle of (angle pt1 pt2)
for a distance of half the distance of pt1 lt2  (/ (distance pt1 pt2) 2)))

Clayer is also a system variable and can be set with the setvar function like this
(setvar "clayer" "s-beam")

I noticed you did not set the angle in the insert command. To make it the same angle
as the line use (angle pt1 pt2)

So the changes look like this, so far
Code: [Select]
(defun c:bm (/ pt1 pt2 pt3 newpt1 newpt2)
(setq pt1 (getpoint "\nPick First Beam Point:")
        pt2 (getpoint pt1 "\nPick Second Beam Point:"))
   ;comment here
(setvar "clayer" "s-beam")
(setq newpt1 (polar pt1 (angle pt1 pt2) 3))
(setq newpt2 (polar pt2 (angle pt2 pt1) 3))
(setq pt3 (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2)))
(entmake (list '(0 . "LINE")
          (cons 10 newpt1)
          (cons 11 newpt2)
 
          )
    )
(setvar "clayer" "s-bm-text")
(COMMAND "-insert" "BM-TEXT" pt3 "" "" (angle pt1 pt2))
(princ)
)   ;end defun


Now using -layer with the M option how would you deal with the layers you have chosen?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CADaver

  • Guest
line with attribute tool
« Reply #23 on: December 03, 2004, 09:00:07 AM »
nevermind, my bad.

whdjr

  • Guest
line with attribute tool
« Reply #24 on: December 03, 2004, 10:00:12 AM »
Here's a little thought:

Instead of using
Code: [Select]
(setvar "clayer" "s-beam")
why not just add this
Code: [Select]
'(2 . "s-beam") to the entmake command. :D

However; regardless of which way you choose you should definitely check to see if the layer is already there.  I'm sure this process will get to error checking eventually. :D

Good Luck and Happy Coding.

Fuccaro

  • Guest
line with attribute tool
« Reply #25 on: December 04, 2004, 01:39:18 AM »
Quote from: whdjr
However; regardless of which way you choose you should definitely check to see if the layer is already there.

ENTMAKE will create a new layer if it doesn't exists. So if you use the '(8 . "s-beam") expression as Whdjr suggested the line will be placed on the layer s-beam. If that layer doesn't exists, it will be firstly created.

dubb

  • Swamp Rat
  • Posts: 1105
line with attribute tool
« Reply #26 on: December 06, 2004, 05:56:50 PM »
thank you very much for the code suggestions.

i have tried to use
Code: [Select]

(command "layer" "make" "S-BEAM" "color" 5 "" "")^c
(command "clayer" "s-beam")


to add my layer if it wasnt there but
Code: [Select]

'(8 . "s-beam")

 is wayt much simpler. what does the
Quote
8
represent?

whdjr

  • Guest
line with attribute tool
« Reply #27 on: December 06, 2004, 06:02:42 PM »
It is the DXF reference tag for Layer Name.

Look up DXF Reference in the autolisp help file.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
line with attribute tool
« Reply #28 on: December 06, 2004, 06:03:44 PM »
The '8' represents the DXF code for the layer of all entites. Take a look around here for one of the layer app's, you'll see how it was used.
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
line with attribute tool
« Reply #29 on: December 06, 2004, 06:04:26 PM »
dang!! beat by one minute. :D
TheSwamp.org  (serving the CAD community since 2003)